📄 samp4.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>#include "ProDtmAxis.h"
#define C_PRINT(a) printf ( "%s\n", a);
ProFileName UserMsg;
/*---------------------- Function Prototypes -------------------------*/
ProError ProDemoDatumAxisCreate();
/*--------------------------------------------------------------------*\Application global data\*--------------------------------------------------------------------*/static uiCmdAccessState TestAccessDefault(uiCmdAccessMode access_mode){ return (ACCESS_AVAILABLE);}/*===========================================================================*\ 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]){
int i, menu_id;
ProError status;
uiCmdCmdId cmd_id;
/*----------------------------------------------------------------*\
消息文件
\*----------------------------------------------------------------*/
ProStringToWstring (UserMsg, "msg.txt");
status = ProMessageDisplay (UserMsg, "USER %0s", "Demo of creating datum axis.\n");
/*---------------------------------------------------------------------*\
Add new button to the menu bar
\*---------------------------------------------------------------------*/
status = ProCmdActionAdd("MyCmd",
(uiCmdCmdActFn)ProDemoDatumAxisCreate,
uiProe2ndImmediate, TestAccessDefault,
PRO_B_TRUE, PRO_B_TRUE, &cmd_id);
status = ProMenubarmenuPushbuttonAdd(
"File", "MyCmd", "Create Datum Axis", "Create Datum Axis",
"File.psh_exit", PRO_B_TRUE, cmd_id, UserMsg);
return (0);
}
/*====================================================================*\
FUNCTION : user_terminate()
PURPOSE : To handle any termination actions
\*====================================================================*/
void user_terminate()
{
}
/*===============================================================*\
FUNCTION : ProDemoDatumAxisCreate
PURPOSE : Demonstrates the creation of Datum Axis Feature
\*===============================================================*/
ProError ProDemoDatumAxisCreate()
{
ProErrorlist errors;
ProMdl model;
ProModelitem model_item;
ProSelection model_sel;
ProFeature feature;
ProFeatureCreateOptions opts[1];
ProAsmcomppath *p_comp_path = NULL;
ProValue value;
char name[PRO_NAME_SIZE];
ProError status;
ProElement pro_e_feature_tree;
ProElement pro_e_feature_type;
ProElement pro_e_std_feature_name;
ProElement pro_e_dtmaxis_constraints;
ProElement pro_e_dtmaxis_constraint;
ProElement pro_e_dtmaxis_constr_type;
ProElement pro_e_dtmaxis_constr_ref;
ProName wide_string;
ProValueData value_data;
ProSelection * p_select;
int n_select;
ProBoolean is_interactive = PRO_B_TRUE;
/*---------------------------------------------------------------*\
Populating root element PRO_E_FEATURE_TREE
\*---------------------------------------------------------------*/
C_PRINT( " *** Processing Element PRO_E_FEATURE_TREE *** " );
status = ProElementAlloc ( PRO_E_FEATURE_TREE, &pro_e_feature_tree );
/*---------------------------------------------------------------*\
Populating element PRO_E_FEATURE_TYPE
\*---------------------------------------------------------------*/
C_PRINT( " *** Processing Element PRO_E_FEATURE_TYPE *** " );
status = ProElementAlloc ( PRO_E_FEATURE_TYPE, &pro_e_feature_type );
value_data.type = PRO_VALUE_TYPE_INT;
value_data.v.i = PRO_FEAT_DATUM_AXIS; /* 926 */
status = ProValueAlloc ( &value );
status = ProValueDataSet ( value, &value_data );
status = ProElementValueSet ( pro_e_feature_type, value );
status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL,
pro_e_feature_type );
/*---------------------------------------------------------------*\
Populating element PRO_E_STD_FEATURE_NAME
\*---------------------------------------------------------------*/
C_PRINT( " *** Processing Element PRO_E_STD_FEATURE_NAME *** " );
status = ProElementAlloc ( PRO_E_STD_FEATURE_NAME, &pro_e_std_feature_name );
ProStringToWstring ( wide_string, "MY_A_1" );
value_data.type = PRO_VALUE_TYPE_WSTRING;
value_data.v.w = wide_string;
status = ProValueAlloc ( &value );
status = ProValueDataSet ( value, &value_data );
status = ProElementValueSet ( pro_e_std_feature_name, value );
status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL,
pro_e_std_feature_name );
/*---------------------------------------------------------------*\
Populating element PRO_E_DTMAXIS_CONSTRAINTS
\*---------------------------------------------------------------*/
C_PRINT( " *** Processing Element PRO_E_DTMAXIS_CONSTRAINTS *** " );
status = ProElementAlloc ( PRO_E_DTMAXIS_CONSTRAINTS,
&pro_e_dtmaxis_constraints );
status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL,
pro_e_dtmaxis_constraints );
/*---------------------------------------------------------------*\
Populating element PRO_E_DTMAXIS_CONSTRAINTS
-> PRO_E_DTMAXIS_CONSTRAINT
\*---------------------------------------------------------------*/
C_PRINT( " *** Processing Element PRO_E_DTMAXIS_CONSTRAINT *** " );
status = ProElementAlloc ( PRO_E_DTMAXIS_CONSTRAINT,
&pro_e_dtmaxis_constraint );
status = ProElemtreeElementAdd ( pro_e_dtmaxis_constraints, NULL,
pro_e_dtmaxis_constraint );
/*---------------------------------------------------------------*\
Populating element PRO_E_DTMAXIS_CONSTRAINTS
-> PRO_E_DTMAXIS_CONSTRAINT
-> PRO_E_DTMAXIS_CONSTR_TYPE
\*---------------------------------------------------------------*/
C_PRINT( " *** Processing Element PRO_E_DTMAXIS_CONSTR_TYPE *** " );
status = ProElementAlloc ( PRO_E_DTMAXIS_CONSTR_TYPE,
&pro_e_dtmaxis_constr_type );
value_data.type = PRO_VALUE_TYPE_INT;
value_data.v.i = PRO_DTMAXIS_CONSTR_TYPE_THRU; /* 1 ProDtmaxisConstrType */
status = ProValueAlloc ( &value );
status = ProValueDataSet ( value, &value_data );
status = ProElementValueSet ( pro_e_dtmaxis_constr_type, value );
status = ProElemtreeElementAdd ( pro_e_dtmaxis_constraint, NULL,
pro_e_dtmaxis_constr_type );
/*---------------------------------------------------------------*\
Populating element PRO_E_DTMAXIS_CONSTRAINTS
-> PRO_E_DTMAXIS_CONSTRAINT
-> PRO_E_DTMAXIS_CONSTR_REF
\*---------------------------------------------------------------*/
C_PRINT( " *** Processing Element PRO_E_DTMAXIS_CONSTR_REF *** " );
status = ProMessageDisplay ( UserMsg, "Select a reference Surface");
printf ( "Please select datum,surface,sldface,qltface_ID_5 type of Modelitem\n");
status = ProSelect ( "datum,surface,sldface,qltface", -1, NULL, NULL,
NULL, NULL, &p_select, &n_select );
if ( n_select <= 0 ) return -1;
status = ProElementAlloc ( PRO_E_DTMAXIS_CONSTR_REF,
&pro_e_dtmaxis_constr_ref );
value_data.type = PRO_VALUE_TYPE_SELECTION;
value_data.v.r = p_select[0];
status = ProValueAlloc ( &value );
status = ProValueDataSet ( value, &value_data );
status = ProElementValueSet ( pro_e_dtmaxis_constr_ref, value );
status = ProElemtreeElementAdd ( pro_e_dtmaxis_constraint, NULL,
pro_e_dtmaxis_constr_ref );
/*---------------------------------------------------------------*\
Populating element PRO_E_DTMAXIS_CONSTRAINTS
-> PRO_E_DTMAXIS_CONSTRAINT
-> PRO_E_DTMAXIS_CONSTR_REF
\*---------------------------------------------------------------*/
C_PRINT( " *** Processing Element PRO_E_DTMAXIS_CONSTRAINT *** " );
status = ProElementAlloc ( PRO_E_DTMAXIS_CONSTRAINT,
&pro_e_dtmaxis_constraint );
status = ProElemtreeElementAdd ( pro_e_dtmaxis_constraints, NULL,
pro_e_dtmaxis_constraint );
/*---------------------------------------------------------------*\
Populating element PRO_E_DTMAXIS_CONSTRAINTS
-> PRO_E_DTMAXIS_CONSTRAINT
-> PRO_E_DTMAXIS_CONSTR_TYPE
\*---------------------------------------------------------------*/
C_PRINT( " *** Processing Element PRO_E_DTMAXIS_CONSTR_TYPE *** " );
status = ProElementAlloc ( PRO_E_DTMAXIS_CONSTR_TYPE,
&pro_e_dtmaxis_constr_type );
value_data.type = PRO_VALUE_TYPE_INT;
value_data.v.i = PRO_DTMAXIS_CONSTR_TYPE_THRU; /* 1 ProDtmaxisConstrType */
status = ProValueAlloc ( &value );
status = ProValueDataSet ( value, &value_data );
status = ProElementValueSet ( pro_e_dtmaxis_constr_type, value );
status = ProElemtreeElementAdd ( pro_e_dtmaxis_constraint, NULL,
pro_e_dtmaxis_constr_type );
/*---------------------------------------------------------------*\
Populating element PRO_E_DTMAXIS_CONSTRAINTS
-> PRO_E_DTMAXIS_CONSTRAINT
-> PRO_E_DTMAXIS_CONSTR_REF
\*---------------------------------------------------------------*/
C_PRINT( " *** Processing Element PRO_E_DTMAXIS_CONSTR_REF *** " );
status = ProMessageDisplay ( UserMsg, "Select a reference Surface");
printf ( "Please select datum,surface,sldface,qltface_ID_5 type of Modelitem\n");
status = ProSelect ( "datum,surface,sldface,qltface_ID_5", -1, NULL,
NULL,
NULL, NULL, &p_select, &n_select );
if ( n_select <= 0 ) return -1;
status = ProElementAlloc ( PRO_E_DTMAXIS_CONSTR_REF,
&pro_e_dtmaxis_constr_ref );
value_data.type = PRO_VALUE_TYPE_SELECTION;
value_data.v.r = p_select[0];
status = ProValueAlloc ( &value );
status = ProValueDataSet ( value, &value_data );
status = ProElementValueSet ( pro_e_dtmaxis_constr_ref, value );
status = ProElemtreeElementAdd ( pro_e_dtmaxis_constraint, NULL,
pro_e_dtmaxis_constr_ref );
/*---------------------------------------------------------------*\
Create the feature in the current model.
\*---------------------------------------------------------------*/
status = ProMdlCurrentGet (&model);
if ( status != PRO_TK_NO_ERROR ) return ( status );
status = ProMdlToModelitem( model, &model_item );
status = ProSelectionAlloc (p_comp_path, &model_item,
&model_sel);
opts[0] = PRO_FEAT_CR_DEFINE_MISS_ELEMS;
status = ProFeatureCreate (model_sel, pro_e_feature_tree, opts, 1,
&feature, &errors);
status = ProElementFree (&pro_e_feature_tree );
return (status);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -