📄 samp2.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 "ProDtmPnt.h"
#define C_PRINT(a) printf ( "%s\n", a);
#define EPSM6 1.0e-6
typedef struct mtrx_data{
ProVector x_axis[2];
ProVector y_axis[2];
ProMatrix sec_trf;
ProMatrix sk_mtrx;
ProSelection sk_plane;
double angle;
}Matrix_data;
ProSelection *temp2 = NULL;
ProSelection *temp1 = NULL;
/*---------------------- Function Prototypes -------------------------*/
ProError ProDemoSketchedPointCreate();
ProError UserSectionPointBuild ( ProSection section, ProSelection *sketch_refs);
/*------------------------- External Data ----------------------------*/
ProError ProDemoSectCreate();
/*------------------------- Global Data -----------------------------*/
ProFileName UserMsg;
/*--------------------------------------------------------------------*\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])
{
ProError status;
uiCmdCmdId cmd_id;
/*----------------------------------------------------------------*\
消息文件
\*----------------------------------------------------------------*/
ProStringToWstring (UserMsg, "msg.txt");
status = ProMessageDisplay (UserMsg, "USER %0s", "Demo of Create Sketched Point.\n");
/*---------------------------------------------------------------------*\
Add new button to the menu bar
\*---------------------------------------------------------------------*/
status = ProCmdActionAdd("MyCmd",
(uiCmdCmdActFn)ProDemoSketchedPointCreate,
uiProe2ndImmediate, TestAccessDefault,
PRO_B_TRUE, PRO_B_TRUE, &cmd_id);
status = ProMenubarmenuPushbuttonAdd(
"File", "MyCmd", "Create Sketched Point", "Create Sketched Point",
"File.psh_exit", PRO_B_TRUE, cmd_id, UserMsg);
return (0);
}
/*====================================================================*\
FUNCTION : user_terminate()
PURPOSE : To handle any termination actions
\*====================================================================*/
void user_terminate()
{
}
/*===============================================================*\
FUNCTION : ProDemoSketchedPointCreate
PURPOSE : Demonstrates the creation of the extruded protrusion
base feature.
\*===============================================================*/
ProError ProDemoSketchedPointCreate()
{
ProErrorlist errors;
ProMdl model;
ProModelitem model_item;
ProSelection model_sel;
ProFeature feature;
ProFeatureCreateOptions opts[1];
ProElempath path;
ProElempathItem path_items[2];
ProSection section;
ProAsmcomppath comp_path;
ProAsmcomppath *p_comp_path = NULL;
ProValue value;
ProBoolean alloc;
ProElement sketch_element;
ProElement created_elemtree;
ProElement pro_e_feature_tree;
ProElement pro_e_feature_type;
ProElement pro_e_dpoint_type;
ProElement pro_e_std_feature_name;
ProElement pro_e_std_section;
ProElement pro_e_std_sec_method;
ProElement pro_e_std_sec_setup_plane;
ProElement pro_e_std_sec_plane;
ProElement pro_e_std_sec_plane_view_dir;
ProElement pro_e_std_sec_plane_orient_dir;
ProElement pro_e_std_sec_plane_orient_ref;
ProSelection *sketch_refs;
ProName wide_string;
ProError status;
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_POINT; /* 931 */
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_DPOINT_TYPE
\*---------------------------------------------------------------*/
C_PRINT( " *** Processing Element PRO_E_DPOINT_TYPE *** " );
status = ProElementAlloc ( PRO_E_DPOINT_TYPE, &pro_e_dpoint_type );
value_data.type = PRO_VALUE_TYPE_INT;
value_data.v.i = PRO_DPOINT_TYPE_SKETCHED; /* 22 ProDPointType */
status = ProValueAlloc ( &value );
status = ProValueDataSet ( value, &value_data );
status = ProElementValueSet ( pro_e_dpoint_type, value );
status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL,
pro_e_dpoint_type );
/*---------------------------------------------------------------*\
Populating optional 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_PNT1" );
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 compound element PRO_E_STD_SECTION
\*---------------------------------------------------------------*/
C_PRINT( " *** Processing Element PRO_E_STD_SECTION *** " );
status = ProElementAlloc ( PRO_E_STD_SECTION, &pro_e_std_section );
status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL,
pro_e_std_section );
sketch_refs = ( ProSelection *) calloc ( 2, sizeof ( ProSelection ));
/*---------------------------------------------------------------*\
Populating element PRO_E_STD_SECTION
-> PRO_E_STD_SEC_SETUP_PLANE
\*---------------------------------------------------------------*/
C_PRINT( " *** Processing Element PRO_E_STD_SEC_SETUP_PLANE *** " );
status = ProElementAlloc ( PRO_E_STD_SEC_SETUP_PLANE,
&pro_e_std_sec_setup_plane );
status = ProElemtreeElementAdd ( pro_e_std_section, NULL,
pro_e_std_sec_setup_plane );
/*---------------------------------------------------------------*\
Populating element PRO_E_STD_SECTION
-> PRO_E_STD_SEC_SETUP_PLANE
-> PRO_E_STD_SEC_PLANE
\*---------------------------------------------------------------*/
C_PRINT( " *** Processing Element PRO_E_STD_SEC_PLANE *** " );
status = ProMessageDisplay ( UserMsg, "Select Surface for sketch placement");
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;
else
{
status = ProSelectionCopy( p_select[0], &sketch_refs[0]);
}
status = ProElementAlloc ( PRO_E_STD_SEC_PLANE, &pro_e_std_sec_plane );
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_std_sec_plane, value );
status = ProElemtreeElementAdd ( pro_e_std_sec_setup_plane, NULL,
pro_e_std_sec_plane );
/*---------------------------------------------------------------*\
Populating element PRO_E_STD_SECTION
-> PRO_E_STD_SEC_SETUP_PLANE
-> PRO_E_STD_SEC_PLANE_VIEW_DIR
\*---------------------------------------------------------------*/
C_PRINT( " *** Processing Element PRO_E_STD_SEC_PLANE_VIEW_DIR *** " );
status = ProElementAlloc ( PRO_E_STD_SEC_PLANE_VIEW_DIR,
&pro_e_std_sec_plane_view_dir );
value_data.type = PRO_VALUE_TYPE_INT;
value_data.v.i = PRO_SEC_VIEW_DIR_SIDE_ONE; /* 1 */
status = ProValueAlloc ( &value );
status = ProValueDataSet ( value, &value_data );
status = ProElementValueSet ( pro_e_std_sec_plane_view_dir, value );
status = ProElemtreeElementAdd ( pro_e_std_sec_setup_plane, NULL,
pro_e_std_sec_plane_view_dir );
/*---------------------------------------------------------------*\
Populating element PRO_E_STD_SECTION
-> PRO_E_STD_SEC_SETUP_PLANE
-> PRO_E_STD_SEC_PLANE_ORIENT_DIR
\*---------------------------------------------------------------*/
C_PRINT( " *** Processing Element PRO_E_STD_SEC_PLANE_ORIENT_DIR *** " );
status = ProElementAlloc ( PRO_E_STD_SEC_PLANE_ORIENT_DIR,
&pro_e_std_sec_plane_orient_dir );
value_data.type = PRO_VALUE_TYPE_INT;
value_data.v.i = PRO_SEC_ORIENT_DIR_UP; /* 1 */
status = ProValueAlloc ( &value );
status = ProValueDataSet ( value, &value_data );
status = ProElementValueSet ( pro_e_std_sec_plane_orient_dir, value );
status = ProElemtreeElementAdd ( pro_e_std_sec_setup_plane, NULL,
pro_e_std_sec_plane_orient_dir );
/*---------------------------------------------------------------*\
Populating element PRO_E_STD_SECTION
-> PRO_E_STD_SEC_SETUP_PLANE
-> PRO_E_STD_SEC_PLANE_ORIENT_REF
\*---------------------------------------------------------------*/
C_PRINT( " *** Processing Element PRO_E_STD_SEC_PLANE_ORIENT_REF *** " );
status = ProMessageDisplay ( UserMsg, "Select Surface for sketch orientation");
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;
else
{
status = ProSelectionCopy( p_select[0], &sketch_refs[1]);
}
status = ProElementAlloc ( PRO_E_STD_SEC_PLANE_ORIENT_REF,
&pro_e_std_sec_plane_orient_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_std_sec_plane_orient_ref, value );
status = ProElemtreeElementAdd ( pro_e_std_sec_setup_plane, NULL,
pro_e_std_sec_plane_orient_ref );
/*---------------------------------------------------------------*\
Creating incomplete 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_INCOMPLETE_FEAT;
status = ProFeatureCreate (model_sel, pro_e_feature_tree, opts, 1,
&feature, &errors);
/* Using the element tree from created feature */
status = ProFeatureElemtreeCreate ( &feature, &created_elemtree );
/*---------------------------------------------------------------*\
Getting the initialized section element from the database.
\*---------------------------------------------------------------*/
/* path to PRO_E_SKETCHER element */
path_items[0].type = PRO_ELEM_PATH_ITEM_TYPE_ID;
path_items[0].path_item.elem_id = PRO_E_STD_SECTION;
path_items[1].type = PRO_ELEM_PATH_ITEM_TYPE_ID;
path_items[1].path_item.elem_id = PRO_E_SKETCHER;
status = ProElempathAlloc (&path);
status = ProElempathDataSet (path, path_items, 2);
status = ProElemtreeElementGet (created_elemtree, path,
&sketch_element);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -