Pro/E特徵訪問之一:訪問孔特徵

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);
}
posted @ 2010-04-07 15:02  samyangvs05  阅读(279)  评论(0编辑  收藏  举报