|
马上注册,结交更多同行朋友,交流,分享,学习。
您需要 登录 才可以下载或查看,没有帐号?注册
x
TOOl的例子里,想void Check() 功能,获取当前零件的孔的列表
typedef struct surface_visit_data
{
FILE *fp;
ProSolid part;
} AxisVisitData_t;
/*===============================================================*\
FUNCTION: UserDemoAxisAct()
PURPOSE : Axis-visit action function that writes the
axis name to a file
\*===============================================================*/
ProError UserDemoAxisAct(
ProAxis axis,
ProError filt_status,
ProAppData app_data)
{
ProError status;
AxisVisitData_t *p_data = (AxisVisitData_t*)app_data;
ProSolid part = p_data->part;
FILE *fp = p_data->fp;
int id;
ProModelitem modelitem;
ProFeature feature;
ProFeattype ftype;
ProName wname;
char name[PRO_NAME_SIZE];
ProSelection selection;
/*---------------------------------------------------------------*\
Get the axis identifier.
\*---------------------------------------------------------------*/
status = ProAxisIdGet (axis, [$id)]
if (status != PRO_TK_NO_ERROR)
return (status);
/*---------------------------------------------------------------*\
Make a ProModelitem handle for the axis.
\*---------------------------------------------------------------*/
status = ProModelitemInit (part, id, PRO_AXIS, [$modelitem)]
if (status != PRO_TK_NO_ERROR)
return (status);
/*---------------------------------------------------------------*\
Get the feature to which the axis belongs.
\*---------------------------------------------------------------*/
status = ProGeomitemFeatureGet ([$modelitem, &feature)]
if (status != PRO_TK_NO_ERROR)
return (status);
/*---------------------------------------------------------------*\
Get the feature type.
\*---------------------------------------------------------------*/
status = ProFeatureTypeGet ([$feature, &ftype)]
if (status != PRO_TK_NO_ERROR)
return (status);
/*---------------------------------------------------------------*\
If the type was not HOLE, skip it.
\*---------------------------------------------------------------*/
if (ftype != PRO_FEAT_HOLE )
return (PRO_TK_NO_ERROR);
/*---------------------------------------------------------------*\
Get the name of the axis.
\*---------------------------------------------------------------*/
status = ProModelitemNameGet ([$modelitem, wname)]
if (status != PRO_TK_NO_ERROR)
return (status);
ProWstringToString (name, wname);
/*---------------------------------------------------------------*\
Print out the axis name and hole identifier.
\*---------------------------------------------------------------*/
fprintf (fp, "Axis %s belongs to hole feature %d\n", name,
feature.id);
/*---------------------------------------------------------------*\
Highlight the owning hole.
\*---------------------------------------------------------------*/
ProSelectionAlloc (NULL, [$feature, &selection)]
ProSelectionHighlight (selection, PRO_COLOR_HIGHLITE);
ProSelectionFree ([$selection)]
return (PRO_TK_NO_ERROR);
}
/*===============================================================*\
FUNCTION: UserDemoHoleList()
PURPOSE: List the axes that belong to the hole features in
a part, and report their names.
\*===============================================================*/
ProError UserDemoHoleList(
ProSolid part)
{
ProError status;
AxisVisitData_t data;
data.part = part;
/*---------------------------------------------------------------*\
Open the text file.
\*---------------------------------------------------------------*/
data.fp = fopen ("visit_test.dat","w");
/*---------------------------------------------------------------*\
Visit all the axes using the visit and filter functions
above. Pass the owning solid and the text file pointer
using the app_data argument.
\*---------------------------------------------------------------*/
status = ProSolidAxisVisit (part, UserDemoAxisAct,
NULL, (ProAppData)[$data)]
/*---------------------------------------------------------------*\
Close the file
\*---------------------------------------------------------------*/
fclose (data.fp);
return (PRO_TK_NO_ERROR);
}
这个函数为帮助中的Example 5: Listing Holes in a Model
如何将这段代码加入void Check() |
|