Example 4: Creating an Offset Csys Datum Point This example shows how to creatfe an Offset Datum Point at an offset from a specified coordinate system. The user is prompted to select the coordinate system. /*====================================================================*\ Creating an Offset Csys Datum Point \*====================================================================*/ /*---------------------- Pro/Toolkit Includes ------------------------*/ #include "ProToolkit.h" #include "ProFeature.h" #include "ProElemId.h" #include "ProExtrude.h" #include "ProModFeat.h" #include "ProStdSection.h" #include "ProElement.h" #include "ProElempath.h" #include "ProFeatType.h" #include "ProFeatForm.h" #include "ProSelection.h" #include "ProSection.h" #include "ProDtmPnt.h" #define C_PRINT(a) printf ( "%s\n", a); /*---------------------- Function Prototypes -------------------------*/ ProError ProDemoOffsetPointCreate(); /*------------------------- External Data ----------------------------*/ /*------------------------- Global Data -----------------------------*/ /*===============================================================*\ FUNCTION : ProDemoOffsetPointCreate PURPOSE : Demonstrates the creation of the extruded protrusion base feature. \*===============================================================*/ ProError ProDemoOffsetPointCreate() { 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_dpoint_type; ProElement pro_e_dpoint_ofst_csys_type; ProElement pro_e_dpoint_ofst_csys_ref; ProElement pro_e_dpoint_ofst_csys_with_dims; ProElement pro_e_dpoint_ofst_csys_pnts_array; ProElement pro_e_dpoint_ofst_csys_pnt; ProElement pro_e_dpoint_ofst_csys_pnt_name; ProElement pro_e_dpoint_ofst_csys_dir1_val; ProElement pro_e_dpoint_ofst_csys_dir2_val; ProElement pro_e_dpoint_ofst_csys_dir3_val; ProName wide_string; ProValueData value_data; ProSelection * p_select; int n_select; ProBoolean is_interactive = PRO_B_TRUE; ProStringToWstring ( message_file, "utilities.txt" ); /*---------------------------------------------------------------*\ 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_OFFSET_CSYS; /* 6 */ 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 element PRO_E_DPOINT_OFST_CSYS_TYPE \*---------------------------------------------------------------*/ C_PRINT( " *** Processing Element PRO_E_DPOINT_OFST_CSYS_TYPE *** " ); status = ProElementAlloc (PRO_E_DPOINT_OFST_CSYS_TYPE, &pro_e_dpoint_ofst_csys_type ); value_data.type = PRO_VALUE_TYPE_INT; value_data.v.i = PRO_DTMPNT_OFFCSYS_CARTESIAN; /* 0 */ status = ProValueAlloc ( &value ); status = ProValueDataSet ( value, &value_data ); status = ProElementValueSet ( pro_e_dpoint_ofst_csys_type, value ); status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_dpoint_ofst_csys_type ); /*---------------------------------------------------------------*\ Populating element PRO_E_DPOINT_OFST_CSYS_REF \*---------------------------------------------------------------*/ C_PRINT( " *** Processing Element PRO_E_DPOINT_OFST_CSYS_REF *** " ); status = ProMessageDisplay ( message_file, "Select a reference CSYS"); printf ( "Please select csys_ID_25 type of Modelitem\n"); status = ProSelect ( "csys", -1, NULL, NULL, NULL, NULL, &p_select, &n_select ); if ( n_select <= 0 ) return -1; status = ProElementAlloc ( PRO_E_DPOINT_OFST_CSYS_REF, &pro_e_dpoint_ofst_csys_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_dpoint_ofst_csys_ref, value ); status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_dpoint_ofst_csys_ref ); /*---------------------------------------------------------------*\ Populating element PRO_E_DPOINT_OFST_CSYS_WITH_DIMS \*---------------------------------------------------------------*/ C_PRINT( " *** Processing Element PRO_E_DPOINT_OFST_CSYS_WITH_DIMS *** " ); status = ProElementAlloc ( PRO_E_DPOINT_OFST_CSYS_WITH_DIMS, &pro_e_dpoint_ofst_csys_with_dims ); value_data.type = PRO_VALUE_TYPE_INT; value_data.v.i = PRO_B_TRUE; status = ProValueAlloc ( &value ); status = ProValueDataSet ( value, &value_data ); status = ProElementValueSet ( pro_e_dpoint_ofst_csys_with_dims, value ); status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_dpoint_ofst_csys_with_dims ); /*---------------------------------------------------------------*\ Populating array element PRO_E_DPOINT_OFST_CSYS_PNTS_ARRAY \*---------------------------------------------------------------*/ C_PRINT( " *** Processing Element PRO_E_DPOINT_OFST_CSYS_PNTS_ARRAY *** " ); status = ProElementAlloc ( PRO_E_DPOINT_OFST_CSYS_PNTS_ARRAY, &pro_e_dpoint_ofst_csys_pnts_array ); status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_dpoint_ofst_csys_pnts_array ); /*---------------------------------------------------------------*\ Populating element PRO_E_DPOINT_OFST_CSYS_PNTS_ARRAY -> PRO_E_DPOINT_OFST_CSYS_PNT \*---------------------------------------------------------------*/ C_PRINT( " *** Processing Element PRO_E_DPOINT_OFST_CSYS_PNT *** " ); status = ProElementAlloc ( PRO_E_DPOINT_OFST_CSYS_PNT, &pro_e_dpoint_ofst_csys_pnt ); status = ProElemtreeElementAdd ( pro_e_dpoint_ofst_csys_pnts_array, NULL, pro_e_dpoint_ofst_csys_pnt ); /*---------------------------------------------------------------*\ Populating element PRO_E_DPOINT_OFST_CSYS_PNTS_ARRAY -> PRO_E_DPOINT_OFST_CSYS_PNT -> PRO_E_DPOINT_OFST_CSYS_PNT_NAME \*---------------------------------------------------------------*/ C_PRINT( " *** Processing Element PRO_E_DPOINT_OFST_CSYS_PNT_NAME *** " ); status = ProElementAlloc ( PRO_E_DPOINT_OFST_CSYS_PNT_NAME, &pro_e_dpoint_ofst_csys_pnt_name ); ProStringToWstring ( wide_string, "PNT2" ); 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_dpoint_ofst_csys_pnt_name, value ); status = ProElemtreeElementAdd ( pro_e_dpoint_ofst_csys_pnt, NULL, pro_e_dpoint_ofst_csys_pnt_name ); /*---------------------------------------------------------------*\ Populating element PRO_E_DPOINT_OFST_CSYS_PNTS_ARRAY -> PRO_E_DPOINT_OFST_CSYS_PNT -> PRO_E_DPOINT_OFST_CSYS_DIR1_VAL \*---------------------------------------------------------------*/ C_PRINT( " *** Processing Element PRO_E_DPOINT_OFST_CSYS_DIR1_VAL *** " ); status = ProElementAlloc ( PRO_E_DPOINT_OFST_CSYS_DIR1_VAL, &pro_e_dpoint_ofst_csys_dir1_val ); value_data.type = PRO_VALUE_TYPE_DOUBLE; value_data.v.d = 100.000000; status = ProValueAlloc ( &value ); status = ProValueDataSet ( value, &value_data ); status = ProElementValueSet ( pro_e_dpoint_ofst_csys_dir1_val, value ); status = ProElemtreeElementAdd ( pro_e_dpoint_ofst_csys_pnt, NULL, pro_e_dpoint_ofst_csys_dir1_val ); /*---------------------------------------------------------------*\ Populating element PRO_E_DPOINT_OFST_CSYS_PNTS_ARRAY -> PRO_E_DPOINT_OFST_CSYS_PNT -> PRO_E_DPOINT_OFST_CSYS_DIR2_VAL \*---------------------------------------------------------------*/ C_PRINT( " *** Processing Element PRO_E_DPOINT_OFST_CSYS_DIR2_VAL *** " ); status = ProElementAlloc ( PRO_E_DPOINT_OFST_CSYS_DIR2_VAL, &pro_e_dpoint_ofst_csys_dir2_val ); value_data.type = PRO_VALUE_TYPE_DOUBLE; value_data.v.d = 200.000000; status = ProValueAlloc ( &value ); status = ProValueDataSet ( value, &value_data ); status = ProElementValueSet ( pro_e_dpoint_ofst_csys_dir2_val, value ); status = ProElemtreeElementAdd ( pro_e_dpoint_ofst_csys_pnt, NULL, pro_e_dpoint_ofst_csys_dir2_val ); /*---------------------------------------------------------------*\ Populating element PRO_E_DPOINT_OFST_CSYS_PNTS_ARRAY -> PRO_E_DPOINT_OFST_CSYS_PNT -> PRO_E_DPOINT_OFST_CSYS_DIR3_VAL \*---------------------------------------------------------------*/ C_PRINT( " *** Processing Element PRO_E_DPOINT_OFST_CSYS_DIR3_VAL *** " ); status = ProElementAlloc ( PRO_E_DPOINT_OFST_CSYS_DIR3_VAL, &pro_e_dpoint_ofst_csys_dir3_val ); value_data.type = PRO_VALUE_TYPE_DOUBLE; value_data.v.d = 300.000000; status = ProValueAlloc ( &value ); status = ProValueDataSet ( value, &value_data ); status = ProElementValueSet ( pro_e_dpoint_ofst_csys_dir3_val, value ); status = ProElemtreeElementAdd ( pro_e_dpoint_ofst_csys_pnt, NULL, pro_e_dpoint_ofst_csys_dir3_val ); /*---------------------------------------------------------------*\ Creating 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); }