找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 5456|回复: 3

[求助] 拉伸的程序

[复制链接]

30

主题

38

回帖

0

威望

助工

积分
84
发表于 2015-2-21 19:27 | 显示全部楼层 |阅读模式
  1. int UsrCreatDefDtm_gear(ProDtmplnConstrType pro_dtmpln_def,ProName dtm_name,ProGeomitem *pln)
  2. {
  3.   ProError         status;
  4.   ProElement elem_tree,elem_type,elem_consts,elem_const,elem_const_type;
  5.   ProValueData     value_data;
  6.   ProValue         value;
  7.   ProModelitem     model_modelitem;
  8.   ProSelection     mdl_sel;
  9.   ProFeature       feature;
  10.   ProErrorlist     errors;
  11.   ProSolid solid;

  12.   ProElementAlloc (PRO_E_FEATURE_TREE, &elem_tree);

  13.   ProElementAlloc (PRO_E_FEATURE_TYPE/*基准平面特征元素,代表特征类型*/, &elem_type);
  14.   value_data.type = PRO_VALUE_TYPE_INT/*数据类型*/;
  15.   value_data.v.i = PRO_FEAT_DATUM/*有效值*/;
  16.   ProValueAlloc (&value);
  17.   ProValueDataSet (value, &value_data);
  18.   ProElementValueSet (elem_type, value); //设置一个单值元素
  19.   ProElemtreeElementAdd (elem_tree, NULL, elem_type);

  20.   ProElementAlloc (PRO_E_DTMPLN_CONSTRAINTS/*基准平面特征元素,代表约束*/, &elem_consts);
  21.   ProElemtreeElementAdd (elem_tree, NULL, elem_consts);

  22.   ProElementAlloc (PRO_E_DTMPLN_CONSTRAINT/*基准平面特征元素,代表约束*/, & elem_const);
  23.   ProElemtreeElementAdd (elem_consts, NULL, elem_const);
  24.    
  25.   ProElementAlloc (PRO_E_DTMPLN_CONSTR_TYPE/*基准平面特征元素,代表类型*/, &elem_const_type);
  26.   value_data.type = PRO_VALUE_TYPE_INT;/*数据类型*/
  27.   value_data.v.i = pro_dtmpln_def;/*有效值是ProDtemplnConstrType*/
  28.   ProValueAlloc (&value);
  29.   ProValueDataSet (value, &value_data);
  30.   ProElementValueSet(elem_const_type, value);  //设置一个单值元素
  31.   ProElemtreeElementAdd (elem_const, NULL,elem_const_type);

  32.   ProMdlCurrentGet((ProMdl*)&solid);//为当前编辑的模型提供ProMdl句柄
  33.   ProMdlToModelitem(solid, &model_modelitem);
  34.   ProSelectionAlloc(NULL, &model_modelitem, &mdl_sel);

  35.   ProFeatureCreate (mdl_sel, elem_tree, NULL, 0,&feature,&errors);
  36.   status=ProModelitemNameSet(&feature,dtm_name);

  37.   status=ProFeatureRedefine(NULL, &feature, elem_tree, NULL, 0, &errors);
  38. // UsrGeomitemPlnGet_gear(feature,pln);

  39.   ProElementFree (&elem_tree);
  40.   
  41.   if(status!=PRO_TK_NO_ERROR)//
  42.         {
  43.          AfxMessageBox(_T("1"));
  44.           return status;
  45.         }
  46.   ProSelectionFree (&mdl_sel);
  47.   return (status);

  48. }
  49. void CreatDefDtm()///创建三个基准面
  50. {
  51.    
  52.         ProName dtm_name;
  53.    UsrCreatDefDtm_gear(PRO_DTMPLN_DEF_X,ProStringToWstring (dtm_name, "RIGHT1"),&geomright);
  54.    UsrCreatDefDtm_gear(PRO_DTMPLN_DEF_Y,ProStringToWstring (dtm_name, "TOP1"),&geomtop);
  55.    UsrCreatDefDtm_gear(PRO_DTMPLN_DEF_Z,ProStringToWstring (dtm_name, "FRONT1"),&geomfront);

  56.   ProSelectionAlloc(NULL, &geomright, &right);
  57.   ProSelectionAlloc(NULL, &geomtop, &top);
  58.   ProSelectionAlloc(NULL, &geomfront, &front);
  59. }

  60. /*圆形*/int UserCreateSection(ProSection section)
  61. {        AfxMessageBox(_T("22"));
  62.         ProError err;
  63. Pro2dCircledef circle;
  64. int                        circle_id;

  65.    
  66.         circle.center[0]=0.0;
  67.         circle.center[1]=0.0;
  68.         circle.radius=maxr;
  69.          circle.type=PRO_2D_CIRCLE;AfxMessageBox(_T("24"));
  70.         err=ProSectionEntityAdd (section,(Pro2dEntdef*)&circle, &circle_id);
  71.         if(err!=PRO_TK_NO_ERROR)
  72.         {AfxMessageBox(_T("25"));}
  73. AfxMessageBox(_T("23"));
  74. return (1);
  75. }

  76. ProError UserSectionBuild_gear(ProSection section)
  77. {
  78.     ProError status;
  79.         int ent_id;
  80.     ProWSecerror serrors1;
  81.         ProWSecerror serrors2;
  82.         ProSecerrorAlloc(&serrors1);
  83.     ProSecerrorAlloc(&serrors2);
  84.         //AfxMessageBox(_T("11"));
  85.     if(!UserCreateSection(section))
  86.         {AfxMessageBox(_T("8"));
  87.           return (PRO_TK_NO_ERROR);
  88.         }

  89. AfxMessageBox(_T("9"));
  90.          ProSectionEntityFromProjection(section,top, &ent_id);
  91.          ProSectionEntityFromProjection(section,right, &ent_id);
  92.      status = ProSectionEpsilonSet( section, 0.1 );
  93.     status= ProSectionAutodim(section, &serrors1);
  94.     status = ProSectionRegenerate ( section,&serrors2 );
  95.          //ProSecerrorFree(&serrors);
  96.          AfxMessageBox(_T("10"));
  97.      return (status) ;
  98. }
  99. ProError lashen()
  100. {
  101.   ProErrorlist            errors;
  102.   ProMdl                  model;
  103.   ProModelitem            model_item;
  104.   ProSelection            model_sel;
  105.   ProFeature              feature;
  106.   ProFeatureCreateOptions opts[1];
  107.   ProElempath             path;
  108.   ProElempathItem         path_items[2];
  109.   ProSection              section;
  110.   ProAsmcomppath          comp_path;
  111.   ProAsmcomppath          *p_comp_path = NULL;
  112.   ProValue                value;

  113.   ProElement sketch_element;
  114.   ProElement created_elemtree;
  115.   
  116.   ProElement pro_e_feature_tree;
  117.   ProElement pro_e_feature_form;
  118.   ProElement pro_e_ext_surf_cut_solid_type;
  119. ProElement pro_e_remove_material;
  120.   ProElement pro_e_feat_form_is_thin;
  121.   ProElement pro_e_std_direction;
  122.   ProElement pro_e_std_matrlside;

  123.   ProElement pro_e_std_ext_depth;
  124.   ProElement pro_e_ext_depth_from;
  125.   ProElement pro_e_ext_depth_from_type;

  126.   ProElement pro_e_ext_depth_to;
  127.   ProElement pro_e_ext_depth_to_type;
  128.     ProElement pro_e_ext_depth_from_value;
  129.   ProElement pro_e_std_section;
  130.   ProElement pro_e_std_sec_setup_plane;
  131.   ProElement pro_e_std_sec_plane;
  132.   ProElement pro_e_std_sec_plane_view_dir;
  133.   ProElement pro_e_std_sec_plane_orient_dir;
  134.   ProElement pro_e_std_sec_plane_orient_ref;

  135.   ProError         status;
  136.   ProValueData         value_data;

  137. CreatDefDtm();////创建默认基准平面


  138.   status = ProElementAlloc/*为元素分配内存*/ ( PRO_E_FEATURE_TREE/*输入元素标识*/, &pro_e_feature_tree/*输出特征元素*/);
  139.   ProElement pro_e_feature_type;
  140.   ProElementAlloc/*为元素分配内存*/ ( PRO_E_FEATURE_TYPE/*基准平面特征元素,代表特征类型*/, &pro_e_feature_type );
  141.   value_data.type = PRO_VALUE_TYPE_INT/*数据类型*/;
  142.   value_data.v.i = PRO_FEAT_PROTRUSION;/*有效值为PRO_FEAT_DATUM*/
  143.   status = ProValueAlloc ( &value );
  144.   status = ProValueDataSet ( value, &value_data );
  145.   status = ProElementValueSet ( pro_e_feature_type, value );//设置一个单值元素
  146.   status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_feature_type );

  147.   status = ProElementAlloc /*为元素分配内存*/( PRO_E_FEATURE_FORM, &pro_e_feature_form );
  148.   value_data.type = PRO_VALUE_TYPE_INT;
  149.   value_data.v.i = PRO_EXTRUDE;
  150.   status = ProValueAlloc ( &value );
  151.   status = ProValueDataSet ( value, &value_data );
  152.   status = ProElementValueSet ( pro_e_feature_form, value );//设置一个单值元素
  153.   status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_feature_form );

  154.   status = ProElementAlloc( PRO_E_EXT_SURF_CUT_SOLID_TYPE, &pro_e_ext_surf_cut_solid_type );
  155.   value_data.type = PRO_VALUE_TYPE_INT;
  156.   value_data.v.i = PRO_EXT_FEAT_TYPE_SOLID;
  157.   status = ProValueAlloc ( &value );
  158.   status = ProValueDataSet ( value, &value_data );
  159.   status = ProElementValueSet ( pro_e_ext_surf_cut_solid_type, value );//设置一个单值元素
  160.   status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_ext_surf_cut_solid_type );

  161.   status = ProElementAlloc ( PRO_E_REMOVE_MATERIAL, &pro_e_remove_material );
  162.   value_data.type = PRO_VALUE_TYPE_INT;
  163.   value_data.v.i = PRO_EXT_MATERIAL_ADD;
  164.   status = ProValueAlloc ( &value );
  165.   status = ProValueDataSet ( value, &value_data );
  166.   status = ProElementValueSet ( pro_e_remove_material, value );//设置一个单值元素
  167.   status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_remove_material );

  168.   status = ProElementAlloc ( PRO_E_FEAT_FORM_IS_THIN, &pro_e_feat_form_is_thin );
  169.   value_data.type = PRO_VALUE_TYPE_INT;
  170.   value_data.v.i = PRO_EXT_FEAT_FORM_NO_THIN;
  171.   status = ProValueAlloc ( &value );
  172.   status = ProValueDataSet ( value, &value_data );
  173.   status = ProElementValueSet ( pro_e_feat_form_is_thin, value );//设置一个单值元素
  174.   status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_feat_form_is_thin );

  175.   status = ProElementAlloc ( PRO_E_STD_SECTION, &pro_e_std_section );
  176.   status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_std_section  );
  177.   status = ProElementAlloc ( PRO_E_STD_SEC_SETUP_PLANE, &pro_e_std_sec_setup_plane );
  178.   status = ProElemtreeElementAdd ( pro_e_std_section, NULL, pro_e_std_sec_setup_plane  );

  179.   status = ProElementAlloc ( PRO_E_STD_SEC_PLANE, &pro_e_std_sec_plane );
  180.   value_data.type = PRO_VALUE_TYPE_SELECTION;
  181.   value_data.v.r =/*sketch_refs[0]*/front;/*草绘平面*/
  182.   status = ProValueAlloc ( &value );
  183.   status = ProValueDataSet ( value, &value_data );
  184.   status = ProElementValueSet ( pro_e_std_sec_plane, value );//设置一个单值元素
  185.   status = ProElemtreeElementAdd ( pro_e_std_sec_setup_plane, NULL, pro_e_std_sec_plane );

  186.   status = ProElementAlloc ( PRO_E_STD_SEC_PLANE_VIEW_DIR, &pro_e_std_sec_plane_view_dir );
  187.   value_data.type = PRO_VALUE_TYPE_INT;
  188.   value_data.v.i = PRO_SEC_VIEW_DIR_SIDE_ONE;/*平面方向*/
  189.   status = ProValueAlloc ( &value );
  190.   status = ProValueDataSet ( value, &value_data );
  191.   status = ProElementValueSet ( pro_e_std_sec_plane_view_dir, value );//设置一个单值元素
  192.   status = ProElemtreeElementAdd ( pro_e_std_sec_setup_plane, NULL, pro_e_std_sec_plane_view_dir );

  193.   status = ProElementAlloc ( PRO_E_STD_SEC_PLANE_ORIENT_DIR, &pro_e_std_sec_plane_orient_dir );
  194.   value_data.type = PRO_VALUE_TYPE_INT;
  195.   value_data.v.i = PRO_SEC_ORIENT_DIR_UP; /*定位方向*/
  196.   status = ProValueAlloc ( &value );
  197.   status = ProValueDataSet ( value, &value_data );
  198.   status = ProElementValueSet ( pro_e_std_sec_plane_orient_dir, value );//设置一个单值元素
  199.   status = ProElemtreeElementAdd ( pro_e_std_sec_setup_plane, NULL, pro_e_std_sec_plane_orient_dir );

  200.   status = ProElementAlloc ( PRO_E_STD_SEC_PLANE_ORIENT_REF, &pro_e_std_sec_plane_orient_ref );
  201.   value_data.type = PRO_VALUE_TYPE_SELECTION;
  202.   value_data.v.r = /*sketch_refs[1]*/top;/*参照基准*/
  203.   status = ProValueAlloc ( &value );
  204.   status = ProValueDataSet ( value, &value_data );
  205.   status = ProElementValueSet ( pro_e_std_sec_plane_orient_ref, value );//设置一个单值元素
  206.   status = ProElemtreeElementAdd ( pro_e_std_sec_setup_plane, NULL, pro_e_std_sec_plane_orient_ref );

  207.   status = ProElementAlloc ( PRO_E_STD_EXT_DEPTH, &pro_e_std_ext_depth );
  208.   status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_std_ext_depth  );

  209.   status = ProElementAlloc ( PRO_E_EXT_DEPTH_FROM, &pro_e_ext_depth_from );
  210.   status = ProElemtreeElementAdd ( pro_e_std_ext_depth, NULL, pro_e_ext_depth_from  );
  211.   ///*
  212.   status = ProElementAlloc ( PRO_E_EXT_DEPTH_FROM_TYPE, &pro_e_ext_depth_from_type );
  213.   value_data.type = PRO_VALUE_TYPE_INT;
  214.   value_data.v.i = PRO_EXT_DEPTH_FROM_BLIND;//
  215.   status = ProValueAlloc ( &value );
  216.   status = ProValueDataSet ( value, &value_data );
  217.   status = ProElementValueSet ( pro_e_ext_depth_from_type, value );//设置一个单值元素
  218.   status = ProElemtreeElementAdd ( pro_e_ext_depth_from, NULL, pro_e_ext_depth_from_type );

  219.   status = ProElementAlloc ( PRO_E_EXT_DEPTH_FROM_VALUE, &pro_e_ext_depth_from_value );
  220.   value_data.type = PRO_VALUE_TYPE_DOUBLE;
  221.   value_data.v.d = houdu;///////////
  222.   status = ProValueAlloc ( &value );
  223.   status = ProValueDataSet ( value, &value_data );
  224.   status = ProElementValueSet ( pro_e_ext_depth_from_value, value );//设置一个单值元素
  225.   status = ProElemtreeElementAdd ( pro_e_ext_depth_from, NULL, pro_e_ext_depth_from_value );
  226.   
  227.   status = ProElementAlloc ( PRO_E_EXT_DEPTH_TO, &pro_e_ext_depth_to );
  228.   status = ProElemtreeElementAdd ( pro_e_std_ext_depth, NULL, pro_e_ext_depth_to  );

  229.   status = ProElementAlloc ( PRO_E_EXT_DEPTH_TO_TYPE, &pro_e_ext_depth_to_type );
  230.   value_data.type = PRO_VALUE_TYPE_INT;
  231.   value_data.v.i = PRO_EXT_DEPTH_SYMMETRIC;
  232.   status = ProValueAlloc ( &value );
  233.   status = ProValueDataSet ( value, &value_data );
  234.   status = ProElementValueSet ( pro_e_ext_depth_to_type, value );//设置一个单值元素
  235.   status = ProElemtreeElementAdd ( pro_e_ext_depth_to, NULL, pro_e_ext_depth_to_type );

  236.   status = ProMdlCurrentGet (&model);
  237.   if ( status != PRO_TK_NO_ERROR )
  238.   {return(status) ;}
  239.   status = ProMdlToModelitem( model, &model_item );
  240.   status = ProSelectionAlloc (p_comp_path, &model_item, &model_sel);
  241.   opts[0] = PRO_FEAT_CR_INCOMPLETE_FEAT;
  242.   status = ProFeatureCreate (model_sel, pro_e_feature_tree, opts, 1,&feature, &errors);
  243.   status = ProFeatureElemtreeCreate ( &feature, &created_elemtree );


  244. //从数据库中获得截面元素
  245.   path_items[0].type = PRO_ELEM_PATH_ITEM_TYPE_ID;
  246.   path_items[0].path_item.elem_id = PRO_E_STD_SECTION;
  247.   path_items[1].type = PRO_ELEM_PATH_ITEM_TYPE_ID;
  248.   path_items[1].path_item.elem_id = PRO_E_SKETCHER;
  249.   status = ProElempathAlloc (&path);
  250.   status = ProElempathDataSet (path, path_items, 2);
  251.    status = ProElemtreeElementGet ( created_elemtree, path, &sketch_element);
  252.   //AfxMessageBox(_T("14"));
  253.   //if ( status != PRO_TK_NO_ERROR )
  254.   //{AfxMessageBox(_T("15"));}
  255.   status = ProElementValueGet ( sketch_element, &value);
  256.   /*AfxMessageBox(_T("18"));
  257.   if ( status != PRO_TK_NO_ERROR )
  258.   {AfxMessageBox(_T("17"));}*/
  259.   status = ProValueDataGet (value, &value_data);
  260.   section = (ProSection)value_data.v.p;
  261. //AfxMessageBox(_T("26"));
  262.   ProElempathFree (&path);
  263.   //AfxMessageBox(_T("27"));
  264.   //构建和求解截面
  265.   status=UserSectionBuild_gear (( ProSection )(value_data.v.p));
  266.   //ProElempathFree (&path);

  267. AfxMessageBox(_T("19"));
  268.   path_items[0].type = PRO_ELEM_PATH_ITEM_TYPE_ID;
  269.   path_items[0].path_item.elem_id = PRO_E_STD_MATRLSIDE;
  270.     status = ProElempathAlloc (&path);//分配新的空ProElempath对象
  271.   status = ProElempathDataSet (path, path_items, 1);//通过从一个ProElempathItem结构中复制数据来设置一个ProElempath的内容
  272.   status = ProElemtreeElementGet ( created_elemtree, path, &pro_e_std_matrlside);//读取特征元素树中的一个指定元素
  273.   status = ProElementValueGet ( pro_e_std_matrlside, &value );//提供一个带单值元素的ProValue对象
  274.   value_data.type = PRO_VALUE_TYPE_INT;
  275.   value_data.v.i = PRO_EXT_MATERIAL_SIDE_ONE;
  276.   status = ProValueDataSet ( value, &value_data );
  277.   status = ProElementValueSet ( pro_e_std_matrlside, value );//设置一个单值元素
  278.   ProElempathFree (&path);//释放ProElempath
  279. AfxMessageBox(_T("5"));
  280.         path_items[0].type = PRO_ELEM_PATH_ITEM_TYPE_ID;
  281.         path_items[0].path_item.elem_id = PRO_E_STD_DIRECTION;
  282.         status = ProElempathAlloc (&path);//分配新的空ProElempath对象
  283.         status = ProElempathDataSet (path, path_items, 1);//通过从一个ProElempathItem结构中复制数据来设置一个ProElempath的内容
  284.         status = ProElemtreeElementGet ( created_elemtree, path,&pro_e_std_direction);//读取特征元素树中的一个指定元素
  285.         status = ProElementValueGet ( pro_e_std_direction, &value );//提供一个带单值元素的ProValue对象
  286.         value_data.type = PRO_VALUE_TYPE_INT;
  287.         value_data.v.i = PRO_EXT_CR_IN_SIDE_TWO;
  288.         status = ProValueDataSet ( value, &value_data );
  289.         status = ProElementValueSet ( pro_e_std_direction, value );//设置一个单值元素
  290.         ProElempathFree (&path);//释放ProElempath
  291. AfxMessageBox(_T("3"));
  292.     opts[0] = PRO_FEAT_CR_DEFINE_MISS_ELEMS;
  293.     //opts[0] = PRO_FEAT_CR_INCOMPLETE_FEAT;
  294.     status = ProSelectionAsmcomppathGet (model_sel, &comp_path);//获取组员成员路径
  295.     AfxMessageBox(_T("6"));
  296.         AfxMessageBox(_T("20"));
  297.         //status = ProFeatureRedefine (NULL, &feature, created_elemtree,opts, 1, &errors);
  298.      status = ProFeatureRedefine (&comp_path, &feature, created_elemtree,opts, 1, &errors);
  299.         AfxMessageBox(_T("21"));
  300.         ProFeatureElemtreeFree(&feature,created_elemtree);
  301.         ProElementFree(&pro_e_feature_tree);
  302. //ProWindowRepaint (PRO_VALUE_UNUSED);
  303.         return (status);
  304. }
复制代码
这是我照着帮助文件写的一个拉伸圆的代码,但是运行到创建草图的时候(函数int UserCreateSection(ProSection section) ),弹框出现了24,没有23和25,也就是说在运行“err=ProSectionEntityAdd (section,(Pro2dEntdef*)&circle, &circle_id);”的时候proe自动退出了,有没有大神帮忙看看是为什么?或者告诉我怎么找到问题在哪里?

3

主题

202

回帖

0

威望

工程师

积分
231
QQ
发表于 2015-2-21 21:17 | 显示全部楼层
什么东东
回复

使用道具 举报

5

主题

165

回帖

3

威望

工程师

积分
208
发表于 2015-2-24 20:46 | 显示全部楼层
艹,为了一个拉伸,写了这么多蛋疼的东西。疯了
回复

使用道具 举报

30

主题

38

回帖

0

威望

助工

积分
84
 楼主| 发表于 2015-2-26 11:39 | 显示全部楼层
我也很蛋疼啊……有什么简单的程序么?求指教
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-11-22 18:13 , Processed in 0.135726 second(s), 22 queries .

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