找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 4781|回复: 3

[求助] 编写的程序运行之后有按钮,但是点击之后没有反应

[复制链接]

30

主题

38

回帖

0

威望

助工

积分
84
发表于 2015-1-30 17:05 | 显示全部楼层 |阅读模式
本帖最后由 withheart 于 2015-1-30 17:57 编辑
  1. extern "C" int user_initialize()
  2. {
  3.      ProError     status;
  4.      //ProFileName  message_file;
  5.          uiCmdCmdId   cmd_id1;
  6.          

  7.          ProFileName MsgFile;
  8.          ProStringToWstring(MsgFile, "text.txt");
  9.          status=ProMenubarMenuAdd ("noncirclegear", "noncirclegear","Utilities", PRO_B_TRUE, MsgFile);

  10.          status = ProCmdActionAdd("noncirclegear",(uiCmdCmdActFn)gear,uiCmdPrioDefault,AccessDefault,PRO_B_TRUE,PRO_B_TRUE,&cmd_id1);
  11.      

  12.          return status;
  13. }
  14. extern "C" void user_terminate()
  15. {
  16.    AFX_MANAGE_STATE(AfxGetStaticModuleState());
  17. }
  18. ProError gear()
  19. {  ProError err;
  20.         /*拉伸圆*/
  21.    err=lashen();
  22.    return(err);
  23. }

  24. /*定义*/
  25. int    z=17;
  26. double        houdu=5,huchang= 31.4591, maxr= 5.25;
  27. ProGeomitem geomfront, geomtop, geomright;//参考面
  28.   ProSelection RIGHT;
  29.   ProSelection TOP;
  30.   ProSelection FRONT;
  31.   ProSelection cylinder_axis;
  32.   ProDimension *dim;
  33. /*函数*/
  34. static uiCmdAccessState AccessDefault (uiCmdAccessMode access_mode)
  35. {
  36.     return (ACCESS_AVAILABLE);
  37. }
  38. /*圆形*/int UserCreateSection(ProSection section/*, ProSection *sketch_refs*/)
  39. {        ProError err;
  40. Pro2dCircledef circle;
  41. int                        line_id[1];

  42.         circle.center[0]=0.0;
  43.         circle.center[1]=0.0;
  44.         circle.radius=maxr;
  45.         circle.type=PRO_2D_CIRCLE;
  46.         err=ProSectionEntityAdd (section,(Pro2dEntdef*)&circle, &line_id[1]);

  47. return (1);
  48. }

  49. ProError UserSectionBuild_gear(ProSection section)
  50. {
  51.     ProError status=PRO_TK_NO_ERROR;
  52.     int ent_id;
  53.     ProWSecerror serrors;
  54.     if(!UserCreateSection(section))//
  55.         {
  56.           return (status);
  57.         }
  58.          ProSectionEntityFromProjection(section,RIGHT, &ent_id);
  59.          status=ProSectionEntityFromProjection(section,TOP , &ent_id);
  60.      ProSecerrorAlloc(&serrors);
  61.      status=ProSectionAutodim(section, &serrors);
  62.      return status ;
  63. }
  64. ProError lashen()
  65. {
  66.   ProErrorlist            errors;
  67.   ProMdl                  model;
  68.   ProModelitem            model_item;
  69.   ProSelection            model_sel;
  70.   ProFeature              feature;
  71.   ProFeatureCreateOptions opts[1];
  72.   ProElempath             path;
  73.   ProElempathItem         path_items[2];
  74.   ProSection              section;
  75.   ProAsmcomppath          comp_path;
  76.   ProAsmcomppath          *p_comp_path = NULL;
  77.   ProValue                value;

  78.   ProElement sketch_element;
  79.   ProElement created_elemtree;
  80.   
  81.   ProElement pro_e_feature_tree;
  82.   ProElement pro_e_feature_form;
  83.   ProElement pro_e_ext_surf_cut_solid_type;
  84.   ProElement pro_e_remove_material;
  85.   ProElement pro_e_feat_form_is_thin;
  86. //  ProElement pro_e_std_direction;
  87. //  ProElement pro_e_std_matrlside;

  88.   ProElement pro_e_std_ext_depth;
  89.   ProElement pro_e_ext_depth_from;
  90.   ProElement pro_e_ext_depth_from_type;

  91.   ProElement pro_e_ext_depth_to;
  92.   ProElement pro_e_ext_depth_to_type;
  93.     ProElement pro_e_ext_depth_to_value;
  94.   ProElement pro_e_std_section;
  95.   ProElement pro_e_std_sec_setup_plane;
  96.   ProElement pro_e_std_sec_plane;
  97.   ProElement pro_e_std_sec_plane_view_dir;
  98.   ProElement pro_e_std_sec_plane_orient_dir;
  99.   ProElement pro_e_std_sec_plane_orient_ref;

  100.   ProError         status;
  101.   ProValueData         value_data;

  102. CreatDefDtm();////创建默认基准平面
  103.   
  104.   status = ProElementAlloc/*为元素分配内存*/ ( PRO_E_FEATURE_TREE/*输入元素标识*/, &pro_e_feature_tree/*输出特征元素*/);
  105.   ProElement pro_e_feature_type;
  106.   ProElementAlloc/*为元素分配内存*/ ( PRO_E_FEATURE_TYPE/*基准平面特征元素,代表特征类型*/, &pro_e_feature_type );
  107.   value_data.type = PRO_VALUE_TYPE_INT/*数据类型*/;
  108.   value_data.v.i = PRO_FEAT_PROTRUSION;/*有效值为PRO_FEAT_DATUM*/
  109.   status = ProValueAlloc ( &value );
  110.   status = ProValueDataSet ( value, &value_data );
  111.   status = ProElementValueSet ( pro_e_feature_type, value );//设置一个单值元素
  112.   status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_feature_type );

  113.   status = ProElementAlloc /*为元素分配内存*/( PRO_E_FEATURE_FORM, &pro_e_feature_form );
  114.   value_data.type = PRO_VALUE_TYPE_INT;
  115.   value_data.v.i = PRO_EXTRUDE;
  116.   status = ProValueAlloc ( &value );
  117.   status = ProValueDataSet ( value, &value_data );
  118.   status = ProElementValueSet ( pro_e_feature_form, value );//设置一个单值元素
  119.   status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_feature_form );

  120.   status = ProElementAlloc/*为元素分配内存*/ ( PRO_E_EXT_SURF_CUT_SOLID_TYPE, &pro_e_ext_surf_cut_solid_type );
  121.   value_data.type = PRO_VALUE_TYPE_INT;
  122.   value_data.v.i = PRO_EXT_FEAT_TYPE_SOLID;
  123.   status = ProValueAlloc ( &value );
  124.   status = ProValueDataSet ( value, &value_data );
  125.   status = ProElementValueSet ( pro_e_ext_surf_cut_solid_type, value );//设置一个单值元素
  126.   status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_ext_surf_cut_solid_type );

  127.   status = ProElementAlloc ( PRO_E_REMOVE_MATERIAL, &pro_e_remove_material );
  128.   value_data.type = PRO_VALUE_TYPE_INT;
  129.   value_data.v.i = PRO_EXT_MATERIAL_ADD;
  130.   status = ProValueAlloc ( &value );
  131.   status = ProValueDataSet ( value, &value_data );
  132.   status = ProElementValueSet ( pro_e_remove_material, value );//设置一个单值元素
  133.   status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_remove_material );

  134.   status = ProElementAlloc ( PRO_E_FEAT_FORM_IS_THIN, &pro_e_feat_form_is_thin );
  135.   value_data.type = PRO_VALUE_TYPE_INT;
  136.   value_data.v.i = PRO_EXT_FEAT_FORM_NO_THIN;
  137.   status = ProValueAlloc ( &value );
  138.   status = ProValueDataSet ( value, &value_data );
  139.   status = ProElementValueSet ( pro_e_feat_form_is_thin, value );//设置一个单值元素
  140.   status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_feat_form_is_thin );

  141.   status = ProElementAlloc ( PRO_E_STD_SECTION, &pro_e_std_section );
  142.   status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_std_section  );
  143.   status = ProElementAlloc ( PRO_E_STD_SEC_SETUP_PLANE, &pro_e_std_sec_setup_plane );
  144.   status = ProElemtreeElementAdd ( pro_e_std_section, NULL, pro_e_std_sec_setup_plane  );

  145.   status = ProElementAlloc ( PRO_E_STD_SEC_PLANE, &pro_e_std_sec_plane );
  146.   value_data.type = PRO_VALUE_TYPE_SELECTION;
  147.   value_data.v.r =/*sketch_refs[0]*/FRONT;
  148.   status = ProValueAlloc ( &value );
  149.   status = ProValueDataSet ( value, &value_data );
  150.   status = ProElementValueSet ( pro_e_std_sec_plane, value );//设置一个单值元素
  151.   status = ProElemtreeElementAdd ( pro_e_std_sec_setup_plane, NULL, pro_e_std_sec_plane );

  152.   status = ProElementAlloc ( PRO_E_STD_SEC_PLANE_VIEW_DIR, &pro_e_std_sec_plane_view_dir );
  153.   value_data.type = PRO_VALUE_TYPE_INT;
  154.   value_data.v.i = PRO_SEC_VIEW_DIR_SIDE_ONE; /* */
  155.   status = ProValueAlloc ( &value );
  156.   status = ProValueDataSet ( value, &value_data );
  157.   status = ProElementValueSet ( pro_e_std_sec_plane_view_dir, value );//设置一个单值元素
  158.   status = ProElemtreeElementAdd ( pro_e_std_sec_setup_plane, NULL, pro_e_std_sec_plane_view_dir );

  159.   status = ProElementAlloc ( PRO_E_STD_SEC_PLANE_ORIENT_DIR, &pro_e_std_sec_plane_orient_dir );
  160.   value_data.type = PRO_VALUE_TYPE_INT;
  161.   value_data.v.i = PRO_SEC_ORIENT_DIR_UP; /* 1 *///
  162.   status = ProValueAlloc ( &value );
  163.   status = ProValueDataSet ( value, &value_data );
  164.   status = ProElementValueSet ( pro_e_std_sec_plane_orient_dir, value );//设置一个单值元素
  165.   status = ProElemtreeElementAdd ( pro_e_std_sec_setup_plane, NULL, pro_e_std_sec_plane_orient_dir );

  166.   status = ProElementAlloc ( PRO_E_STD_SEC_PLANE_ORIENT_REF, &pro_e_std_sec_plane_orient_ref );
  167.   value_data.type = PRO_VALUE_TYPE_SELECTION;
  168.   value_data.v.r = /*sketch_refs[1]*/TOP;//
  169.   status = ProValueAlloc ( &value );
  170.   status = ProValueDataSet ( value, &value_data );
  171.   status = ProElementValueSet ( pro_e_std_sec_plane_orient_ref, value );//设置一个单值元素
  172.   status = ProElemtreeElementAdd ( pro_e_std_sec_setup_plane, NULL, pro_e_std_sec_plane_orient_ref );

  173.   status = ProElementAlloc ( PRO_E_STD_EXT_DEPTH, &pro_e_std_ext_depth );
  174.   status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_std_ext_depth  );

  175.   status = ProElementAlloc ( PRO_E_EXT_DEPTH_FROM, &pro_e_ext_depth_from );
  176.   status = ProElemtreeElementAdd ( pro_e_std_ext_depth, NULL, pro_e_ext_depth_from  );
  177.   ///*
  178.   status = ProElementAlloc ( PRO_E_EXT_DEPTH_FROM_TYPE, &pro_e_ext_depth_from_type );
  179.   value_data.type = PRO_VALUE_TYPE_INT;
  180.   value_data.v.i = PRO_EXT_DEPTH_FROM_NONE;//
  181.   status = ProValueAlloc ( &value );
  182.   status = ProValueDataSet ( value, &value_data );
  183.   status = ProElementValueSet ( pro_e_ext_depth_from_type, value );//设置一个单值元素
  184.   status = ProElemtreeElementAdd ( pro_e_ext_depth_from, NULL, pro_e_ext_depth_from_type );

  185.   status = ProElementAlloc ( PRO_E_EXT_DEPTH_TO, &pro_e_ext_depth_to );
  186.   status = ProElemtreeElementAdd ( pro_e_std_ext_depth, NULL, pro_e_ext_depth_to  );

  187.   status = ProElementAlloc ( PRO_E_EXT_DEPTH_TO_TYPE, &pro_e_ext_depth_to_type );
  188.   value_data.type = PRO_VALUE_TYPE_INT;
  189.   value_data.v.i = PRO_EXT_DEPTH_TO_BLIND;
  190.   status = ProValueAlloc ( &value );
  191.   status = ProValueDataSet ( value, &value_data );
  192.   status = ProElementValueSet ( pro_e_ext_depth_to_type, value );//设置一个单值元素
  193.   status = ProElemtreeElementAdd ( pro_e_ext_depth_to, NULL, pro_e_ext_depth_to_type );

  194.   status = ProElementAlloc ( PRO_E_EXT_DEPTH_TO_VALUE, &pro_e_ext_depth_to_value );
  195.   value_data.type = PRO_VALUE_TYPE_DOUBLE;
  196.   value_data.v.d = houdu;///////////
  197.   status = ProValueAlloc ( &value );
  198.   status = ProValueDataSet ( value, &value_data );
  199.   status = ProElementValueSet ( pro_e_ext_depth_to_value, value );//设置一个单值元素
  200.   status = ProElemtreeElementAdd ( pro_e_ext_depth_to, NULL, pro_e_ext_depth_to_value );

  201.   status = ProMdlCurrentGet (&model);
  202.   if ( status != PRO_TK_NO_ERROR ) return(status) ;
  203.   status = ProMdlToModelitem( model, &model_item );
  204.   status = ProSelectionAlloc (p_comp_path, &model_item, &model_sel);
  205.   
  206.   opts[0] = PRO_FEAT_CR_INCOMPLETE_FEAT;
  207.   status = ProFeatureCreate (model_sel, pro_e_feature_tree, opts, 1,&feature, &errors);

  208.   status = ProFeatureElemtreeCreate ( &feature, &created_elemtree );

  209.   path_items[0].type = PRO_ELEM_PATH_ITEM_TYPE_ID;
  210.   path_items[0].path_item.elem_id = PRO_E_STD_SECTION;
  211.   path_items[1].type = PRO_ELEM_PATH_ITEM_TYPE_ID;
  212.   path_items[1].path_item.elem_id = PRO_E_SKETCHER;
  213.   status = ProElempathAlloc (&path);//分配新的空ProElempath对象
  214.   status = ProElempathDataSet (path, path_items, 2);//通过从一个ProElempathItem结构中复制数据来设置一个ProElempath的内容
  215.   status = ProElemtreeElementGet ( created_elemtree, path, &sketch_element);//读取特征元素树中的一个指定元素
  216.   status = ProElementValueGet ( sketch_element, &value);//提供一个带单值元素的ProValue对象
  217.   status = ProValueDataGet (value, &value_data);
  218.   section = (ProSection)value_data.v.p;
  219.   ProElempathFree (&path);//释放ProElempath


  220.   status = UserSectionBuild_gear (( ProSection )(value_data.v.p));[code]  
  221. opts[0] = PRO_FEAT_CR_INCOMPLETE_FEAT;
  222.     status = ProSelectionAsmcomppathGet (model_sel, &comp_path);//获取组员成员路径
  223.     status = ProFeatureRedefine (NULL, &feature, created_elemtree,opts, 1, &errors);//
  224.     ProElementFree(&pro_e_feature_tree);
  225. return (status);
  226. }

  227. ProSelection *sketch_refs;
  228. /*获得几何项动作函数*/ProError GemitemAction(ProGeomitem* p_geomitems,ProError status,ProAppData app_data)
  229. {
  230.   memcpy(app_data, p_geomitems, sizeof(ProGeomitem));
  231.   return(PRO_TK_E_FOUND);
  232. }
  233. /*获得平面几何项*/void UsrGeomitemPlnGet(ProFeature feature,ProGeomitem *geomitem)
  234. {
  235.   ProFeatureGeomitemVisit(&feature, PRO_SURFACE,(ProGeomitemAction)GemitemAction,NULL,geomitem);
  236. }
  237. int UsrCreatDefDtm(ProDtmplnConstrType pro_dtmpln_def,ProName dtm_name,ProGeomitem *pln)//生成基准面
  238. {
  239.   ProError         status;
  240.   ProElement elem_tree,elem_type,elem_consts,elem_const,elem_const_type;
  241.   ProValueData     value_data;
  242.   ProValue         value;
  243.   ProModelitem     model_modelitem;
  244.   ProSelection     mdl_sel;
  245.   ProFeature       feature;
  246.   ProErrorlist     errors;
  247.   ProSolid solid;

  248.   ProElementAlloc (PRO_E_FEATURE_TREE, &elem_tree);

  249.   ProElementAlloc (PRO_E_FEATURE_TYPE, &elem_type);
  250.   value_data.type = PRO_VALUE_TYPE_INT;
  251.   value_data.v.i = PRO_FEAT_DATUM;
  252.   ProValueAlloc (&value);
  253.   ProValueDataSet (value, &value_data);
  254.   ProElementValueSet (elem_type, value);  
  255.   ProElemtreeElementAdd (elem_tree, NULL, elem_type);

  256.   ProElementAlloc (PRO_E_DTMPLN_CONSTRAINTS, &elem_consts);
  257.   ProElemtreeElementAdd (elem_tree, NULL, elem_consts);

  258.   ProElementAlloc (PRO_E_DTMPLN_CONSTRAINT, & elem_const);
  259.   ProElemtreeElementAdd (elem_consts, NULL, elem_const);

  260.   ProElementAlloc (PRO_E_DTMPLN_CONSTR_TYPE, &elem_const_type);
  261.   value_data.type = PRO_VALUE_TYPE_INT;
  262.   value_data.v.i = pro_dtmpln_def;
  263.   ProValueAlloc (&value);
  264.   ProValueDataSet (value, &value_data);
  265.   ProElementValueSet(elem_const_type, value);  
  266.   ProElemtreeElementAdd (elem_const, NULL,elem_const_type);

  267.   ProMdlCurrentGet((ProMdl*)&solid);
  268.   ProMdlToModelitem(solid, &model_modelitem);
  269.   ProSelectionAlloc(NULL, &model_modelitem, &mdl_sel);

  270.   ProFeatureCreate (mdl_sel, elem_tree, NULL, 0,&feature,&errors);
  271.   status=ProModelitemNameSet(&feature,dtm_name);
  272.   status=ProFeatureRedefine(NULL, &feature, elem_tree, NULL, 0, &errors);
  273.   UsrGeomitemPlnGet(feature,pln);

  274.   ProElementFree (&elem_tree);
  275.   ProSelectionFree (&mdl_sel);
  276.   return (status);
  277. }
  278. void CreatDefDtm()///创建三个基准面
  279. {
  280.    ProGeomitem front, top, right;
  281.    ProName dtm_name;
  282.    UsrCreatDefDtm(PRO_DTMPLN_DEF_X,ProStringToWstring (dtm_name, "RIGHT"),&right);
  283.    UsrCreatDefDtm(PRO_DTMPLN_DEF_Y,ProStringToWstring (dtm_name, "TOP"),&top);
  284.    UsrCreatDefDtm(PRO_DTMPLN_DEF_Z,ProStringToWstring (dtm_name, "FRONT"),&front);
  285. }
复制代码
[/code]

编写的程序运行之后有按钮,但是点击之后没有反应,这可能是什么原因导致的?

这是创建的菜单选项

这是创建的菜单选项

8

主题

240

回帖

0

威望

工程师

积分
323
发表于 2015-1-31 09:37 | 显示全部楼层
能出教程大家学习学习?
回复

使用道具 举报

30

主题

38

回帖

0

威望

助工

积分
84
 楼主| 发表于 2015-1-31 12:55 | 显示全部楼层
???这是求助啊求助啊
回复

使用道具 举报

1

主题

5

回帖

0

威望

实习生

积分
7
发表于 2015-3-31 19:16 | 显示全部楼层
看不懂啊你拉伸怎么要写这么多啊
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

本站为非营利性站点,部分资源为网友搜集或发布,仅供学习和研究使用,如用于商业用途,请购买正版。站内所发布的资源,如有侵犯你的权益,请发邮件联系我们,本站将立即改正或删除。

手机版|小黑屋|野火论坛(©2007~2024) ( 苏ICP备11036728号-2 )苏公网安备 32039102000103号|站长QQ28016688

GMT+8, 2024-11-22 18:41 , Processed in 0.146556 second(s), 23 queries .

快速回复 返回顶部 返回列表