|
本帖最后由 withheart 于 2015-1-30 17:57 编辑
- extern "C" int user_initialize()
- {
- ProError status;
- //ProFileName message_file;
- uiCmdCmdId cmd_id1;
-
- ProFileName MsgFile;
- ProStringToWstring(MsgFile, "text.txt");
- status=ProMenubarMenuAdd ("noncirclegear", "noncirclegear","Utilities", PRO_B_TRUE, MsgFile);
- status = ProCmdActionAdd("noncirclegear",(uiCmdCmdActFn)gear,uiCmdPrioDefault,AccessDefault,PRO_B_TRUE,PRO_B_TRUE,&cmd_id1);
-
- return status;
- }
- extern "C" void user_terminate()
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- }
- ProError gear()
- { ProError err;
- /*拉伸圆*/
- err=lashen();
- return(err);
- }
- /*定义*/
- int z=17;
- double houdu=5,huchang= 31.4591, maxr= 5.25;
- ProGeomitem geomfront, geomtop, geomright;//参考面
- ProSelection RIGHT;
- ProSelection TOP;
- ProSelection FRONT;
- ProSelection cylinder_axis;
- ProDimension *dim;
- /*函数*/
- static uiCmdAccessState AccessDefault (uiCmdAccessMode access_mode)
- {
- return (ACCESS_AVAILABLE);
- }
- /*圆形*/int UserCreateSection(ProSection section/*, ProSection *sketch_refs*/)
- { ProError err;
- Pro2dCircledef circle;
- int line_id[1];
- circle.center[0]=0.0;
- circle.center[1]=0.0;
- circle.radius=maxr;
- circle.type=PRO_2D_CIRCLE;
- err=ProSectionEntityAdd (section,(Pro2dEntdef*)&circle, &line_id[1]);
- return (1);
- }
- ProError UserSectionBuild_gear(ProSection section)
- {
- ProError status=PRO_TK_NO_ERROR;
- int ent_id;
- ProWSecerror serrors;
- if(!UserCreateSection(section))//
- {
- return (status);
- }
- ProSectionEntityFromProjection(section,RIGHT, &ent_id);
- status=ProSectionEntityFromProjection(section,TOP , &ent_id);
- ProSecerrorAlloc(&serrors);
- status=ProSectionAutodim(section, &serrors);
- return status ;
- }
- ProError lashen()
- {
- ProErrorlist errors;
- ProMdl model;
- ProModelitem model_item;
- ProSelection model_sel;
- ProFeature feature;
- ProFeatureCreateOptions opts[1];
- ProElempath path;
- ProElempathItem path_items[2];
- ProSection section;
- ProAsmcomppath comp_path;
- ProAsmcomppath *p_comp_path = NULL;
- ProValue value;
- ProElement sketch_element;
- ProElement created_elemtree;
-
- ProElement pro_e_feature_tree;
- ProElement pro_e_feature_form;
- ProElement pro_e_ext_surf_cut_solid_type;
- ProElement pro_e_remove_material;
- ProElement pro_e_feat_form_is_thin;
- // ProElement pro_e_std_direction;
- // ProElement pro_e_std_matrlside;
- ProElement pro_e_std_ext_depth;
- ProElement pro_e_ext_depth_from;
- ProElement pro_e_ext_depth_from_type;
- ProElement pro_e_ext_depth_to;
- ProElement pro_e_ext_depth_to_type;
- ProElement pro_e_ext_depth_to_value;
- ProElement pro_e_std_section;
- ProElement pro_e_std_sec_setup_plane;
- ProElement pro_e_std_sec_plane;
- ProElement pro_e_std_sec_plane_view_dir;
- ProElement pro_e_std_sec_plane_orient_dir;
- ProElement pro_e_std_sec_plane_orient_ref;
- ProError status;
- ProValueData value_data;
- CreatDefDtm();////创建默认基准平面
-
- status = ProElementAlloc/*为元素分配内存*/ ( PRO_E_FEATURE_TREE/*输入元素标识*/, &pro_e_feature_tree/*输出特征元素*/);
- ProElement pro_e_feature_type;
- ProElementAlloc/*为元素分配内存*/ ( PRO_E_FEATURE_TYPE/*基准平面特征元素,代表特征类型*/, &pro_e_feature_type );
- value_data.type = PRO_VALUE_TYPE_INT/*数据类型*/;
- value_data.v.i = PRO_FEAT_PROTRUSION;/*有效值为PRO_FEAT_DATUM*/
- status = ProValueAlloc ( &value );
- status = ProValueDataSet ( value, &value_data );
- status = ProElementValueSet ( pro_e_feature_type, value );//设置一个单值元素
- status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_feature_type );
- status = ProElementAlloc /*为元素分配内存*/( PRO_E_FEATURE_FORM, &pro_e_feature_form );
- value_data.type = PRO_VALUE_TYPE_INT;
- value_data.v.i = PRO_EXTRUDE;
- status = ProValueAlloc ( &value );
- status = ProValueDataSet ( value, &value_data );
- status = ProElementValueSet ( pro_e_feature_form, value );//设置一个单值元素
- status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_feature_form );
- status = ProElementAlloc/*为元素分配内存*/ ( PRO_E_EXT_SURF_CUT_SOLID_TYPE, &pro_e_ext_surf_cut_solid_type );
- value_data.type = PRO_VALUE_TYPE_INT;
- value_data.v.i = PRO_EXT_FEAT_TYPE_SOLID;
- status = ProValueAlloc ( &value );
- status = ProValueDataSet ( value, &value_data );
- status = ProElementValueSet ( pro_e_ext_surf_cut_solid_type, value );//设置一个单值元素
- status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_ext_surf_cut_solid_type );
- status = ProElementAlloc ( PRO_E_REMOVE_MATERIAL, &pro_e_remove_material );
- value_data.type = PRO_VALUE_TYPE_INT;
- value_data.v.i = PRO_EXT_MATERIAL_ADD;
- status = ProValueAlloc ( &value );
- status = ProValueDataSet ( value, &value_data );
- status = ProElementValueSet ( pro_e_remove_material, value );//设置一个单值元素
- status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_remove_material );
- status = ProElementAlloc ( PRO_E_FEAT_FORM_IS_THIN, &pro_e_feat_form_is_thin );
- value_data.type = PRO_VALUE_TYPE_INT;
- value_data.v.i = PRO_EXT_FEAT_FORM_NO_THIN;
- status = ProValueAlloc ( &value );
- status = ProValueDataSet ( value, &value_data );
- status = ProElementValueSet ( pro_e_feat_form_is_thin, value );//设置一个单值元素
- status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_feat_form_is_thin );
- status = ProElementAlloc ( PRO_E_STD_SECTION, &pro_e_std_section );
- status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_std_section );
- status = ProElementAlloc ( PRO_E_STD_SEC_SETUP_PLANE, &pro_e_std_sec_setup_plane );
- status = ProElemtreeElementAdd ( pro_e_std_section, NULL, pro_e_std_sec_setup_plane );
- status = ProElementAlloc ( PRO_E_STD_SEC_PLANE, &pro_e_std_sec_plane );
- value_data.type = PRO_VALUE_TYPE_SELECTION;
- value_data.v.r =/*sketch_refs[0]*/FRONT;
- status = ProValueAlloc ( &value );
- status = ProValueDataSet ( value, &value_data );
- status = ProElementValueSet ( pro_e_std_sec_plane, value );//设置一个单值元素
- status = ProElemtreeElementAdd ( pro_e_std_sec_setup_plane, NULL, pro_e_std_sec_plane );
- status = ProElementAlloc ( PRO_E_STD_SEC_PLANE_VIEW_DIR, &pro_e_std_sec_plane_view_dir );
- value_data.type = PRO_VALUE_TYPE_INT;
- value_data.v.i = PRO_SEC_VIEW_DIR_SIDE_ONE; /* */
- status = ProValueAlloc ( &value );
- status = ProValueDataSet ( value, &value_data );
- status = ProElementValueSet ( pro_e_std_sec_plane_view_dir, value );//设置一个单值元素
- status = ProElemtreeElementAdd ( pro_e_std_sec_setup_plane, NULL, pro_e_std_sec_plane_view_dir );
- status = ProElementAlloc ( PRO_E_STD_SEC_PLANE_ORIENT_DIR, &pro_e_std_sec_plane_orient_dir );
- value_data.type = PRO_VALUE_TYPE_INT;
- value_data.v.i = PRO_SEC_ORIENT_DIR_UP; /* 1 *///
- status = ProValueAlloc ( &value );
- status = ProValueDataSet ( value, &value_data );
- status = ProElementValueSet ( pro_e_std_sec_plane_orient_dir, value );//设置一个单值元素
- status = ProElemtreeElementAdd ( pro_e_std_sec_setup_plane, NULL, pro_e_std_sec_plane_orient_dir );
- status = ProElementAlloc ( PRO_E_STD_SEC_PLANE_ORIENT_REF, &pro_e_std_sec_plane_orient_ref );
- value_data.type = PRO_VALUE_TYPE_SELECTION;
- value_data.v.r = /*sketch_refs[1]*/TOP;//
- status = ProValueAlloc ( &value );
- status = ProValueDataSet ( value, &value_data );
- status = ProElementValueSet ( pro_e_std_sec_plane_orient_ref, value );//设置一个单值元素
- status = ProElemtreeElementAdd ( pro_e_std_sec_setup_plane, NULL, pro_e_std_sec_plane_orient_ref );
- status = ProElementAlloc ( PRO_E_STD_EXT_DEPTH, &pro_e_std_ext_depth );
- status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_std_ext_depth );
- status = ProElementAlloc ( PRO_E_EXT_DEPTH_FROM, &pro_e_ext_depth_from );
- status = ProElemtreeElementAdd ( pro_e_std_ext_depth, NULL, pro_e_ext_depth_from );
- ///*
- status = ProElementAlloc ( PRO_E_EXT_DEPTH_FROM_TYPE, &pro_e_ext_depth_from_type );
- value_data.type = PRO_VALUE_TYPE_INT;
- value_data.v.i = PRO_EXT_DEPTH_FROM_NONE;//
- status = ProValueAlloc ( &value );
- status = ProValueDataSet ( value, &value_data );
- status = ProElementValueSet ( pro_e_ext_depth_from_type, value );//设置一个单值元素
- status = ProElemtreeElementAdd ( pro_e_ext_depth_from, NULL, pro_e_ext_depth_from_type );
- status = ProElementAlloc ( PRO_E_EXT_DEPTH_TO, &pro_e_ext_depth_to );
- status = ProElemtreeElementAdd ( pro_e_std_ext_depth, NULL, pro_e_ext_depth_to );
- status = ProElementAlloc ( PRO_E_EXT_DEPTH_TO_TYPE, &pro_e_ext_depth_to_type );
- value_data.type = PRO_VALUE_TYPE_INT;
- value_data.v.i = PRO_EXT_DEPTH_TO_BLIND;
- status = ProValueAlloc ( &value );
- status = ProValueDataSet ( value, &value_data );
- status = ProElementValueSet ( pro_e_ext_depth_to_type, value );//设置一个单值元素
- status = ProElemtreeElementAdd ( pro_e_ext_depth_to, NULL, pro_e_ext_depth_to_type );
- status = ProElementAlloc ( PRO_E_EXT_DEPTH_TO_VALUE, &pro_e_ext_depth_to_value );
- value_data.type = PRO_VALUE_TYPE_DOUBLE;
- value_data.v.d = houdu;///////////
- status = ProValueAlloc ( &value );
- status = ProValueDataSet ( value, &value_data );
- status = ProElementValueSet ( pro_e_ext_depth_to_value, value );//设置一个单值元素
- status = ProElemtreeElementAdd ( pro_e_ext_depth_to, NULL, pro_e_ext_depth_to_value );
- status = ProMdlCurrentGet (&model);
- if ( status != PRO_TK_NO_ERROR ) return(status) ;
- status = ProMdlToModelitem( model, &model_item );
- status = ProSelectionAlloc (p_comp_path, &model_item, &model_sel);
-
- opts[0] = PRO_FEAT_CR_INCOMPLETE_FEAT;
- status = ProFeatureCreate (model_sel, pro_e_feature_tree, opts, 1,&feature, &errors);
- status = ProFeatureElemtreeCreate ( &feature, &created_elemtree );
- path_items[0].type = PRO_ELEM_PATH_ITEM_TYPE_ID;
- path_items[0].path_item.elem_id = PRO_E_STD_SECTION;
- path_items[1].type = PRO_ELEM_PATH_ITEM_TYPE_ID;
- path_items[1].path_item.elem_id = PRO_E_SKETCHER;
- status = ProElempathAlloc (&path);//分配新的空ProElempath对象
- status = ProElempathDataSet (path, path_items, 2);//通过从一个ProElempathItem结构中复制数据来设置一个ProElempath的内容
- status = ProElemtreeElementGet ( created_elemtree, path, &sketch_element);//读取特征元素树中的一个指定元素
- status = ProElementValueGet ( sketch_element, &value);//提供一个带单值元素的ProValue对象
- status = ProValueDataGet (value, &value_data);
- section = (ProSection)value_data.v.p;
- ProElempathFree (&path);//释放ProElempath
- status = UserSectionBuild_gear (( ProSection )(value_data.v.p));[code]
- opts[0] = PRO_FEAT_CR_INCOMPLETE_FEAT;
- status = ProSelectionAsmcomppathGet (model_sel, &comp_path);//获取组员成员路径
- status = ProFeatureRedefine (NULL, &feature, created_elemtree,opts, 1, &errors);//
- ProElementFree(&pro_e_feature_tree);
- return (status);
- }
- ProSelection *sketch_refs;
- /*获得几何项动作函数*/ProError GemitemAction(ProGeomitem* p_geomitems,ProError status,ProAppData app_data)
- {
- memcpy(app_data, p_geomitems, sizeof(ProGeomitem));
- return(PRO_TK_E_FOUND);
- }
- /*获得平面几何项*/void UsrGeomitemPlnGet(ProFeature feature,ProGeomitem *geomitem)
- {
- ProFeatureGeomitemVisit(&feature, PRO_SURFACE,(ProGeomitemAction)GemitemAction,NULL,geomitem);
- }
- int UsrCreatDefDtm(ProDtmplnConstrType pro_dtmpln_def,ProName dtm_name,ProGeomitem *pln)//生成基准面
- {
- ProError status;
- ProElement elem_tree,elem_type,elem_consts,elem_const,elem_const_type;
- ProValueData value_data;
- ProValue value;
- ProModelitem model_modelitem;
- ProSelection mdl_sel;
- ProFeature feature;
- ProErrorlist errors;
- ProSolid solid;
- ProElementAlloc (PRO_E_FEATURE_TREE, &elem_tree);
- ProElementAlloc (PRO_E_FEATURE_TYPE, &elem_type);
- value_data.type = PRO_VALUE_TYPE_INT;
- value_data.v.i = PRO_FEAT_DATUM;
- ProValueAlloc (&value);
- ProValueDataSet (value, &value_data);
- ProElementValueSet (elem_type, value);
- ProElemtreeElementAdd (elem_tree, NULL, elem_type);
- ProElementAlloc (PRO_E_DTMPLN_CONSTRAINTS, &elem_consts);
- ProElemtreeElementAdd (elem_tree, NULL, elem_consts);
- ProElementAlloc (PRO_E_DTMPLN_CONSTRAINT, & elem_const);
- ProElemtreeElementAdd (elem_consts, NULL, elem_const);
- ProElementAlloc (PRO_E_DTMPLN_CONSTR_TYPE, &elem_const_type);
- value_data.type = PRO_VALUE_TYPE_INT;
- value_data.v.i = pro_dtmpln_def;
- ProValueAlloc (&value);
- ProValueDataSet (value, &value_data);
- ProElementValueSet(elem_const_type, value);
- ProElemtreeElementAdd (elem_const, NULL,elem_const_type);
- ProMdlCurrentGet((ProMdl*)&solid);
- ProMdlToModelitem(solid, &model_modelitem);
- ProSelectionAlloc(NULL, &model_modelitem, &mdl_sel);
- ProFeatureCreate (mdl_sel, elem_tree, NULL, 0,&feature,&errors);
- status=ProModelitemNameSet(&feature,dtm_name);
- status=ProFeatureRedefine(NULL, &feature, elem_tree, NULL, 0, &errors);
- UsrGeomitemPlnGet(feature,pln);
- ProElementFree (&elem_tree);
- ProSelectionFree (&mdl_sel);
- return (status);
- }
- void CreatDefDtm()///创建三个基准面
- {
- ProGeomitem front, top, right;
- ProName dtm_name;
- UsrCreatDefDtm(PRO_DTMPLN_DEF_X,ProStringToWstring (dtm_name, "RIGHT"),&right);
- UsrCreatDefDtm(PRO_DTMPLN_DEF_Y,ProStringToWstring (dtm_name, "TOP"),&top);
- UsrCreatDefDtm(PRO_DTMPLN_DEF_Z,ProStringToWstring (dtm_name, "FRONT"),&front);
- }
复制代码 [/code]
编写的程序运行之后有按钮,但是点击之后没有反应,这可能是什么原因导致的? |
-
这是创建的菜单选项
|