/*====================================================================*\
FUNCTION : UsrCreateExtrudeFeat(创建拉伸特征)
\*====================================================================*/
void UsrCreateExtrudeFeat(
double depth_value, //(In)拉伸深度
ProGeomitem SketchPln, //(In)草绘平面
ProGeomitem RefPln1, //(In)参照平面1
ProGeomitem RefPln2, //(In)参照平面2
int ProtrusionOrCut, //(In)特征类型
int index, //(In)草图序号
double *dimValue) //(In)直径
{
ProError status;
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;
int ivalue;
int win_id;
ProMdlCurrentGet((ProMdl*)&solid);
/*---------------------------------------------------------------*\
为特征树分配内存
\*---------------------------------------------------------------*/
ProElementAlloc(PRO_E_FEATURE_TREE, &elem_tree);
/*---------------------------------------------------------------*\
向特征树添加特征类型元素
\*---------------------------------------------------------------*/
UsrElemtreeElementAdd(PRO_E_FEATURE_TYPE,elem_tree,
&ProtrusionOrCut,PRO_VALUE_TYPE_INT,&element);
/*---------------------------------------------------------------*\
向特征树添加特征形式元素
\*---------------------------------------------------------------*/
ivalue=PRO_EXTRUDE;
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_PLANE, &setup_elem);
ProElemtreeElementAdd(stdsec_elem, NULL, setup_elem);
/*---------------------------------------------------------------*\
向特征树添加草绘平面元素
\*---------------------------------------------------------------*/
ProElementAlloc(PRO_E_STD_SECTION_PLANE, &secpln_elem);
ProElemtreeElementAdd(setup_elem, NULL, secpln_elem);
/*---------------------------------------------------------------*\
向特征树添加草绘平面设置元素
\*---------------------------------------------------------------*/
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);
/*---------------------------------------------------------------*\
创建非完全特征
\*---------------------------------------------------------------*/
status=ProMdlCurrentGet((ProMdl*)&solid);
if(status!=PRO_TK_NO_ERROR)return(status);
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);
status=ProSectionFree(§ion);
/*---------------------------*\
重新调整模型,使其在当前窗口完全显示
\*--------------------------*/
ProWindowCurrentGet(&win_id);
ProWindowRefit(win_id);
}
/*====================================================================*\
FUNCTION : UsrSectionGet()
从指定特征的元素树中选出草绘器(PRO_E_SKETCHER)元素之值
\*====================================================================*/
int UsrSectionGet(ProFeature *feature, //(In) 特征句柄
int elemId, //(In) 截面标识符
ProSection *section) //(Out) 截面元素
{
ProError status;
ProElempath path;
ProElempathItem path_items[2];
ProValue value;
ProValueData value_data;
*section = NULL;
//设置特征截面元素的路径
path_items[0].type = PRO_ELEM_PATH_ITEM_TYPE_ID;
path_items[0].path_item.elem_id = elemId;
path_items[1].type = PRO_ELEM_PATH_ITEM_TYPE_ID;
path_items[1].path_item.elem_id = PRO_E_SKETCHER;
ProElempathAlloc(&path);
ProElempathDataSet (path, path_items, 2);
//从指定特征中得到路径为path的元素值(非透明的ProValue对象)
status =ProFeatureElemValueGet(feature, path, &value);
if(status != PRO_TK_NO_ERROR)
return(0);
ProElempathFree(&path);
//从非透明的ProValue对象得到用户可以访问的数据对象ProValueData
ProValueDataGet(value, &value_data);
//获得截面元素指针
*section = (ProSection)value_data.v.p;
return(1);
}
粉红色的这个程序是不是有问题啊?这就是李世国书上的,但拉伸出不来啊? |