📄 listhole.c
字号:
/*load head file*/
#include<ProToolkit.h>#include<Pro2dEntdef.h>#include<ProANSI.h>#include<ProAnimate.h>#include<ProArray.h>#include<ProAsmcomp.h>#include<ProAsmcomppath.h>#include<ProAssembly.h>#include<ProAxis.h>#include<ProChamfer.h>#include<ProClCmd.h>#include<ProColor.h>#include<ProComm.h>#include<ProConst.h>#include<ProContour.h>#include<ProContourdata.h>#include<ProCore.h>#include<ProCsys.h>#include<ProCsysdata.h>#include<ProCurve.h>#include<ProCurvedata.h>#include<ProDatumdata.h>#include<ProDisplist.h>#include<ProDtmAxis.h>#include<ProDtmCrv.h>#include<ProDtmCrvSketch.h>#include<ProDtmCsys.h>#include<ProDtmPln.h>#include<ProEdge.h>#include<ProEdgedata.h>#include<ProElemId.h>#include<ProElement.h>#include<ProElempath.h>#include<ProExpldstate.h>#include<ProExtdata.h>#include<ProExtobj.h>#include<ProExtobjCB.h>#include<ProExtobjDisp.h>#include<ProExtobjRef.h>#include<ProExtobjSel.h>#include<ProExtrude.h>#include<ProFaminstance.h>#include<ProFamtable.h>#include<ProFeatForm.h>#include<ProFeatType.h>#include<ProFeature.h>#include<ProFixture.h>#include<ProFlatSrf.h>#include<ProForeignCurve.h>#include<ProGeomitem.h>#include<ProGeomitemdata.h>#include<ProGraphic.h>#include<ProGroup.h>#include<ProHardware.h>#include<ProImportfeat.h>#include<ProIntfData.h>#include<ProItemerr.h>#include<ProLayer.h>#include<ProLayerR19.h>#include<ProMaterial.h>#include<ProMdl.h>#include<ProMenu.h>#include<ProMenuBar.h>#include<ProMessage.h>#include<ProMfg.h>#include<ProMfgoper.h>#include<ProModFeat.h>#include<ProMode.h>#include<ProModelitem.h>#include<ProNcseq.h>#include<ProNcseqElem.h>#include<ProNote.h>#include<ProNotify.h>#include<ProObjects.h>#include<ProParameter.h>#include<ProParamval.h>#include<ProPart.h>#include<ProPattern.h>#include<ProPecktable.h>#include<ProPoint.h>#include<ProProcstep.h>#include<ProQuilt.h>#include<ProQuiltdata.h>#include<ProRelSet.h>#include<ProReplace.h>#include<ProRevolve.h>#include<ProRmdt.h>#include<ProRule.h>#include<ProSecConstr.h>#include<ProSecdim.h>#include<ProSecdimType.h>#include<ProSecerror.h>#include<ProSection.h>#include<ProSelection.h>#include<ProSheetmetal.h>#include<ProSimprep.h>#include<ProSimprepdata.h>#include<ProSizeConst.h>#include<ProSolid.h>#include<ProStdSection.h>#include<ProSurface.h>#include<ProSurfacedata.h>#include<ProSweep.h>#include<ProTool.h>#include<ProToolElem.h>#include<ProToolinput.h>#include<ProUICmd.h>#include<ProUtil.h>#include<ProValue.h>#include<ProVerstamp.h>#include<ProView.h>#include<ProWcell.h>#include<ProWchar.h>#include<ProWindows.h>#include<ProWorkspace.h>#include<ProWstring.h>
/*--------------------------------------------------------------------*\Application global data\*--------------------------------------------------------------------*/static wchar_t MSGFIL[] = {'u','s','e','r','m','s','g','.','t','x','t','\0'};static uiCmdAccessState TestAccessDefault(uiCmdAccessMode access_mode){ return (ACCESS_AVAILABLE);}
/*---------------------- Application Includes ------------------------*/
#include "TestError.h"
/*---------------------- Global Data ------------------------*/
typedef struct surface_visit_data
{
FILE *fp;
ProSolid part;
} AxisVisitData_t;
/*---------------------- Function Prototypes -------------------------*/
ProError UserDemoAxisAct();
ProError UserDemoHoleList();
int UserVisitDemo();
/*===========================================================================*\ Function : main Purpose : Test the ProToolkitMain() function. main is optional function.\*===========================================================================*/main(argc, argv)int argc;char **argv;{ ProToolkitMain(argc, argv); return(0);}/*====================================================================*\FUNCTION : user_initialize()PURPOSE : Pro/DEVELOP standard initialize - define menu button\*====================================================================*/int user_initialize( int argc, char *argv[], wchar_t errbuf[80]){ /* Declare function */ int ProTestInstallationCheck(); int i, menu_id; ProError status; uiCmdCmdId cmd_id;/*---------------------------------------------------------------------*\ Add new button to the menu bar\*---------------------------------------------------------------------*/ status = ProCmdActionAdd("MyCmd",
(uiCmdCmdActFn)UserVisitDemo,
uiProe2ndImmediate, TestAccessDefault,
PRO_B_TRUE, PRO_B_TRUE, &cmd_id);
status = ProMenubarmenuPushbuttonAdd(
"File", "MyCmd", "HoleList", "list hole of model",
"File.psh_exit", PRO_B_TRUE, cmd_id, MSGFIL);
return (0);
}/*====================================================================*\FUNCTION : user_terminate()PURPOSE : To handle any termination actions\*====================================================================*/void user_terminate(){
}
/*====================================================================*\
FUNCTION : UserDemoAxisAct()
PURPOSE : Axis-visit action function, to write 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 id
\*--------------------------------------------------------------------*/
status = ProAxisIdGet(axis, &id);
if(status != PRO_TK_NO_ERROR)
return(status);
/*--------------------------------------------------------------------*\
Make a Modelitem handle for the axis
\*--------------------------------------------------------------------*/
status = ProModelitemInit(part, id, PRO_AXIS, &modelitem);
if(status != PRO_TK_NO_ERROR)
return(status);
/*--------------------------------------------------------------------*\
Get the feature the axis belongs to
\*--------------------------------------------------------------------*/
status = ProGeomitemFeatureGet(&modelitem, &feature);
if(status != PRO_TK_NO_ERROR)
return(status);
/*--------------------------------------------------------------------*\
Get the type of the feature
\*--------------------------------------------------------------------*/
status = ProFeatureTypeGet(&feature, &ftype);
if(status != PRO_TK_NO_ERROR)
return(status);
/*--------------------------------------------------------------------*\
If the type was not HOLE, skip
\*--------------------------------------------------------------------*/
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 id
\*--------------------------------------------------------------------*/
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 : Function to list the axes which belong to 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_hole.dat","w");
/*--------------------------------------------------------------------*\
Visit all the axes using the visit and filter functions above.
Pass the owning sold, and the text file pointer using the app_data argument.
\*--------------------------------------------------------------------*/
status = ProSolidAxisVisit(part, UserDemoAxisAct,
NULL, (ProAppData)&data);
ERROR_CHECK("UserDemoHoleList","ProSolidAxisVisit",status);
/*--------------------------------------------------------------------*\
Close the file
\*--------------------------------------------------------------------*/
fclose(data.fp);
return( PRO_TK_NO_ERROR );
}
/*====================================================================*\
FUNCTION : UserVisitDemo
PURPOSE : call UserDemoHoleList on current model
\*====================================================================*/
int UserVisitDemo( )
{
ProMdl model;
ProError status;
status = ProMdlCurrentGet( &model );
ERROR_CHECK( "UserDemoVisit", "ProMdlCurrentGet", status );
if ( status == PRO_TK_NO_ERROR )
status = UserDemoHoleList( (ProSolid)model );
return( (int)status );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -