列兵
UID2463150
U币0
G币0
技术0
主题15
精华0
阅读权限10
注册时间2010-11-19
最后登录1970-1-1
在线时间0 小时
列兵
|
这是我做的一个拉伸特征的函数,在Pro/e里运行后,Pro/E自动关闭,物品的版本是Pro/E4.0,用的是VS2005的编程软件,高手给看看,呵呵。是不是我用的特征树不完整,或是什么原因,最好能把错误的地方标出来,说明应该怎么改,呵呵。谢谢。
void UsrCreateExtrudeFeat(double depth_value,ProGeomitem SketchPln,
ProGeomitem RefPln1,ProGeomitem RefPln2,
int ProtrusionOrCut,int index,double *dimValue)
{
ProSolid solid;
ProSection section;
ProElement elem_tree,element,stdsec_elem,setup_elem,
depth_elem,depthfrom_elem,depthto_elem,secpln_elem;
ProFeatureCreateOptions opts[1];
ProModelitem modelitem;
ProSelection sel;
ProFeature feature;
ProErrorlist errors;
ProError status;
int ivalue;
ProMdlCurrentGet((ProMdl*)&solid);
//为特征树顶层元素elem_tree分配内存
ProElementAlloc(PRO_E_FEATURE_TREE,&elem_tree);
//向特征树添加特征类型元素element
UsrElemtreeElementAdd(PRO_E_FEATURE_TYPE,elem_tree,&ProtrusionOrCut,PRO_VALUE_TYPE_INT,&element);
//向特征树添加特征形式元素
UsrElemtreeElementAdd(PRO_E_FEATURE_FORM,elem_tree,&ivalue,PRO_VALUE_TYPE_INT,&element);
//向特征树添加标准截面元素
ProElementAlloc(PRO_E_STD_SECTION,&stdsec_elem);
ProElemtreeElementAdd(elem_tree,NULL,stdsec_elem);
//向特征树添加标准截面设置元素
ProElementAlloc(PRO_E_STD_SEC_SETUP,&setup_elem);
ProElemtreeElementAdd(stdsec_elem,NULL,setup_elem);
//向特征树添加标准截面元素(待草绘截面)
status = ProElementAlloc(PRO_E_STD_SEC_PLANE,&secpln_elem);
status = ProElemtreeElementAdd(setup_elem,NULL,secpln_elem);
//向特征树添加草绘平面设置元素
status = ProSelectionAlloc(NULL,&SketchPln,&sel);
UsrElemtreeElementAdd(PRO_E_STD_SEC_PLANE,secpln_elem,&sel,PRO_VALUE_TYPE_SELECTION,&element);
ProSelectionFree(&sel);
//向特征树添加草绘平面方向设置元素
ivalue=PRO_SEC_VIEW_DIR_SIDE_ONE;
UsrElemtreeElementAdd(PRO_E_STD_SEC_PLANE_VIEW_DIR,secpln_elem,&ivalue,PRO_VALUE_TYPE_INT,&element);
//向特征树添加草绘平面定位方向设置元素
ivalue=PRO_SEC_ORIENT_DIR_UP;
UsrElemtreeElementAdd(PRO_E_STD_SEC_PLANE_ORIENT_DIR,secpln_elem,&ivalue,PRO_VALUE_TYPE_INT,&element);
//向特征树添加草绘平面定位参照基准面设置元素
ProSelectionAlloc(NULL,&top,&sel);
UsrElemtreeElementAdd(PRO_E_STD_SEC_PLANE_ORIENT_REF,secpln_elem,&sel,PRO_VALUE_TYPE_SELECTION,&element);
ProSelectionFree(&sel);
//向特征树添加草绘方法元素
ivalue=PRO_SEC_SKETCH;
UsrElemtreeElementAdd(PRO_E_STD_SEC_METHOD,setup_elem,&ivalue,PRO_VALUE_TYPE_INT,&element);
//创建非完全特征
ProMdlCurrentGet((ProMdl*)&solid);
ProMdlToModelitem(solid,&modelitem);
ProSelectionAlloc(NULL,&modelitem,&sel);
opts[0]=PRO_FEAT_CR_INCOMPLETE_FEAT;
ProFeatureCreate(sel,elem_tree,opts,1,&feature,&errors);
ProSelectionFree(&sel);
//从数据库中获得截面元素
UsrSectionGet(&feature,PRO_E_STD_SECTION,§ion);
//构建和求解截面
UsrSectionBuild(&RefPln1,&RefPln2,section,index,dimValue);
//将草绘器元素添加到特征元素树中
UsrElemtreeElementAdd(PRO_E_SKETCHER,stdsec_elem,§ion,PRO_VALUE_TYPE_POINTER,&element);
//拉伸深度定义
ProElementAlloc(PRO_E_STD_EXT_DEPTH,&depth_elem);
ProElemtreeElementAdd(elem_tree,NULL,depth_elem);
//起始面定义
ProElementAlloc(PRO_E_EXT_DEPTH_FROM,&depthfrom_elem);
ProElemtreeElementAdd(depth_elem,NULL,depthfrom_elem);
//拉伸深度类型(给定深度值)
ivalue=PRO_EXT_DEPTH_FROM_BLIND;
UsrElemtreeElementAdd(PRO_E_EXT_DEPTH_FROM_TYPE,depthfrom_elem,&ivalue,PRO_VALUE_TYPE_INT,&element);
//深度值设置
UsrElemtreeElementAdd(PRO_E_EXT_DEPTH_FROM_VALUE,depthfrom_elem,&depth_value,PRO_VALUE_TYPE_DOUBLE,&element);
//终止面定义
ProElementAlloc(PRO_E_EXT_DEPTH_TO,&depthto_elem);
ProElemtreeElementAdd(depth_elem,NULL,depthto_elem);
//终止面深度值
ivalue=PRO_EXT_DEPTH_TO_NONE;
UsrElemtreeElementAdd(PRO_E_EXT_DEPTH_TO_TYPE,depthto_elem,&ivalue,PRO_VALUE_TYPE_INT,&element);
//像特征元素树添加新的深度定义元素后重定义特征
ProFeatureRedefine(NULL,&feature,elem_tree,opts,1,&errors);
ProSectionFree(§ion);
//重新调整模型使其在当前窗口完全显示
int win_id;
ProWindowCurrentGet(&win_id); //获得当前窗口的标识号
ProWindowRefit(win_id); //在当前窗口完全显示模型
}
void UsrElemtreeElementAdd(ProElemId id,ProElement parent,
void *value,ProValueDataType type,ProElement *element)
{
ProValueData value_data;
ProValue pvalue;
value_data.type=type;
//特征元素值类型转换
switch(type)
{
case PRO_VALUE_TYPE_INT:
value_data.v.i=*(int*)value;
break;
case PRO_VALUE_TYPE_DOUBLE:
value_data.v.d=*(double*)value;
break;
case PRO_VALUE_TYPE_POINTER:
value_data.v.p=*(void**)value;
break;
case PRO_VALUE_TYPE_STRING:
value_data.v.s=*(char**)value;
break;
case PRO_VALUE_TYPE_WSTRING:
value_data.v.w=*(wchar_t**)value;
break;
case PRO_VALUE_TYPE_SELECTION:
value_data.v.r=*(ProSelection*)value;
break;
case PRO_VALUE_TYPE_TRANSFORM:
value_data.v.t=*(double***)value;
break;
case PRO_VALUE_TYPE_BOOLEAN:
value_data.v.i=*(int*)value;
break;
}
//设置特征数元素的值
ProElementAlloc(id,element);
ProValueAlloc(&pvalue);
ProValueDataSet(pvalue,&value_data);
ProElementValueSet(*element,pvalue);
//将特征元素添加到特征元素树中
ProElemtreeElementAdd(parent,NULL,*element);
} |
|