void RetrieveAssemblyHierarchyInformation ( const ProSolid p_solid_handle, bool in_IncludeTheEntireHierarchy_NotJustImmediateDependents, CreoModelAssemblyAttributes &out_AssemblyHierarchy ) throw (isis::application_exception) { if ( p_solid_handle == NULL ) { std::stringstream errorString; errorString << "BuildAssemblyHierarchy was passed a NULL pointer for p_solid_handle."; throw isis::application_exception(errorString); } UserAppdata appdata(out_AssemblyHierarchy); ProMdldata mdldata; isis::isis_ProMdlDataGet(p_solid_handle, &mdldata); char name[PRO_NAME_SIZE]; char type[PRO_TYPE_SIZE]; ProWstringToString(name,mdldata.name); ProWstringToString(type,mdldata.type); if ( in_IncludeTheEntireHierarchy_NotJustImmediateDependents) appdata.assemblyHierarchy.includeTheEntireHierarchy = true; else appdata.assemblyHierarchy.includeTheEntireHierarchy = false; if ( strncmp(type,"ASM",3) == 0 ) { appdata.assemblyHierarchy.modelType = PRO_MDL_ASSEMBLY; appdata.assemblyHierarchy.proAsmcomp.type = PRO_TYPE_UNUSED; appdata.assemblyHierarchy.proAsmcomp.id = 0; appdata.assemblyHierarchy.proAsmcomp.owner = 0; } else { // This would be a PRO_MDL_PART std::stringstream errorString; errorString << "BuildAssemblyHierarchy was passed a p_solid_handle that pointed to a model " << type << " type. The only allowed model type is ASM."; throw isis::application_exception(errorString); } appdata.assemblyHierarchy.modelname = mdldata.name; appdata.assemblyHierarchy.p_solid_handle = p_solid_handle; isis::isis_ProSolidFeatVisit(p_solid_handle, user_action, UserAsmCompFilter, &appdata); }
/*============================================================================*\ Function: ProUtilMenuStringsIntValueSelect Purpose: Select a string from menu and return it's number \*============================================================================*/ ProError ProUtilMenuStringsIntValueSelect( char *menu_name, wchar_t **w_ptr, int *output_value) { ProUtilMenuButtons *buttons_array; int i, n_buttons; ProError err; for(n_buttons=1; w_ptr[n_buttons-1][0] != '\0'; n_buttons++); buttons_array = (ProUtilMenuButtons *)calloc(n_buttons+1, sizeof(ProUtilMenuButtons)); ProUtilstrcpy(buttons_array[0].button, (const char *) menu_name); buttons_array[0].special_flag = TEST_CALL_PRO_MENU_DELETE; for(i=1; i<=n_buttons; i++) { ProWstringToString(buttons_array[i].button, w_ptr[i-1]); buttons_array[i].value = i - 1; } err = ProUtilMenuIntValueSelect(buttons_array, output_value); free(buttons_array); return (err); }
/*============================================================================*\ Function: ProUtilMenuToggleDone Purpose: Used from ProUtilMenuStringManySelect \*============================================================================*/ int ProUtilMenuToggleDone( MenuToggleInfo *p_toggle_info, int action) { int i, sel; ProError err; ProCharName name; switch (action) { case SELECT_ALL: case UNSEL_ALL: sel = (action == SELECT_ALL); for (i=0; i<p_toggle_info->n_buttons; i++) if (p_toggle_info->button_status[i] != sel) { ProWstringToString(name, p_toggle_info->w_menu_buttons[i]); err = ProUtilMenubuttonHighlight(p_toggle_info->menu_name, name, sel); p_toggle_info->button_status[i] = sel; } break; case DONE_SEL: case QUIT_SEL: err = ProMenuDeleteWithStatus(action); err = ProMenuDeleteWithStatus(action); break; } return (0); }
void isis_ProModelitemByNameInit_WithDescriptiveErrorMsg( // Added Arguments const std::string &in_ComponentID, const std::string &in_Model_Name, ProMdlType mdltype, // Original arguments ProMdl mdl, ProType type, const ProName name, ProModelitem* p_item ) throw(isis::application_exception) { try { isis::isis_ProModelitemByNameInit (mdl, type, name, p_item); } catch ( isis::application_exception& ex ) { char featureName[ISIS_CHAR_BUFFER_LENGTH]; ProWstringToString(featureName, (wchar_t *)name ); std::stringstream errorString; errorString << "Could not find feature in Creo model:" << std::endl << " Feature Name: " << featureName << std::endl << " Model Name: " << in_Model_Name << std::endl << " Model Type: " << isis::ProMdlType_string(mdltype)<< std::endl << " Component Instance ID: " << in_ComponentID << std::endl << " Exception Message: " << ex.what(); throw isis::application_exception("C05002",errorString.str().c_str()); } }
void RetrieveMaterial( const std::string &in_ModelName, ProSolid part, std::string &out_MaterialName ) throw(isis::application_exception) { ProMaterial material; try { isis::isis_ProMaterialCurrentGet( part, &material ); char stringBuffer[PRO_NAME_SIZE]; // PRO_NAME_SIZE = 32 out_MaterialName = ProWstringToString( stringBuffer, material.matl_name ); } catch (...) { // out_MaterialName = "NOT_DEFINED"; std::string TempError = "Material not defined for part: " + in_ModelName + ". To compute mass properties, all parts must have a material assignment. " + " Please open the model with Creo and select File Prepare \"Model Properties\"" + " to assign a material to the model."; throw isis::application_exception(TempError.c_str()); } }
//////////////////////////////////////////////////////////////////////////////////////////////////////// // Return true if in_MaterialName material exists in in_Part // in_MaterialName length must be < 32 chars bool MaterialExists( ProSolid in_Part, const std::string &in_MaterialName ) throw (isis::application_exception) { std::string MaterialName = isis::ConvertToUpperCase(in_MaterialName); ProName * p_name; isis::isis_ProArrayAlloc(0, sizeof(ProName), 1, (ProArray*) &p_name); isis::isis_ProPartMaterialsGet(in_Part, &p_name); int numLines; isis::isis_ProArraySizeGet((ProArray)p_name, &numLines); char stringBuffer[PRO_NAME_SIZE]; // PRO_NAME_SIZE = 32 for (int i=0; i < numLines; ++i) { ProWstringToString(stringBuffer, p_name[i]); //std::cout << std::endl << stringBuffer; if ( strcmp(MaterialName.c_str(), _strupr(stringBuffer )) == 0 ) { isis::isis_ProArrayFree((ProArray*)&p_name); return true; } } return false; }
void RetrieveCreoMaterialsNames( const std::vector<std::string> &in_ListOfComponentInstanceIDs, std::map<std::string, isis::CADComponentData> &in_CADComponentData_map, std::map<std::string, std::string> &out_ComponentID_to_MaterialName_map ) throw (isis::application_exception) { bool errorOccrred = false; std::stringstream errorNotFoundMaterials; errorNotFoundMaterials << "Material(s) not set in Creo Model(s):"; ProMaterial material; char stringBuffer[PRO_NAME_SIZE]; std::string materialName; for each ( std::string i in in_ListOfComponentInstanceIDs) { if ( in_CADComponentData_map[i].modelType == PRO_PART ) { try { isis::isis_ProMaterialCurrentGet( in_CADComponentData_map[i].modelHandle, &material ); char stringBuffer[PRO_NAME_SIZE]; // PRO_NAME_SIZE = 32 materialName = ProWstringToString( stringBuffer, material.matl_name ); // A component ID should not occurr more than once if ( out_ComponentID_to_MaterialName_map.find(i) != out_ComponentID_to_MaterialName_map.end() ) { std::stringstream errorString; errorString << "Function: RetrieveCreoMaterialsNames, A ComponentInstanceID (" << in_CADComponentData_map[i].componentID << ") appeared more than once in in_ListOfComponentInstanceIDs" << std::endl << "in_ListOfComponentInstanceIDs: " << std::endl; for each ( std::string j in in_ListOfComponentInstanceIDs ) errorString << "ComponentInstanceID: " << i << "ComponentName: " << in_CADComponentData_map[i].name; throw isis::application_exception(errorString.str().c_str()); } out_ComponentID_to_MaterialName_map[i] = materialName; } catch ( isis::application_exception ex ) { errorOccrred = true; errorNotFoundMaterials << std::endl << " Component Instance ID: " << in_CADComponentData_map[i].componentID << std::endl << " Component Name: " << in_CADComponentData_map[i].name << std::endl << " Component Type: " << ProMdlType_string(in_CADComponentData_map[i].modelType) << std::endl << " Exception: " << ex.what() << std::endl; }
std::string GetParametricParameter( const std::string &in_model_name, ProMdl *in_p_model, const std::string &in_ParameterOwner, const std::string &in_ParameterName ) throw (isis::application_exception) { //typedef wchar_t ProName[PRO_NAME_SIZE]; if ( in_ParameterOwner.size() >= PRO_NAME_SIZE ) { char temp_char_array[ISIS_CHAR_BUFFER_LENGTH]; std::string err_str = "exception : Exceeded maximum number of characters. Owner Name: " + std::string(in_ParameterOwner) + ", Maximum allowed characters: " + _itoa(PRO_NAME_SIZE - 1, temp_char_array, 10); isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << err_str; throw isis::application_exception("C01003", err_str); } //typedef wchar_t ProName[PRO_NAME_SIZE]; if ( in_ParameterName.size() >= PRO_NAME_SIZE ) { char temp_char_array[ISIS_CHAR_BUFFER_LENGTH]; std::string err_str = "exception : Exceeded maximum number of characters. Parameter Name: " + std::string(in_ParameterName) + ", Maximum allowed characters: " + _itoa(PRO_NAME_SIZE - 1, temp_char_array, 10); isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << err_str; throw isis::application_exception("C01004", err_str); } char ReadValue[ISIS_CHAR_BUFFER_LENGTH]; try { std::string ParameterOwner_string_upper = ConvertToUpperCase(in_ParameterOwner); ProName ParameterOwner_wchar; ProStringToWstring(ParameterOwner_wchar, (char *)in_ParameterOwner.c_str() ); ProName ParameterName_wchar; ProStringToWstring(ParameterName_wchar, (char *)in_ParameterName.c_str() ); //std::cout << std::endl << "ParameterName: " << ProWstringToString(temp_string, ParameterName_wchar); //std::cout << std::endl << "in_p_model: " << in_p_model; //std::cout << std::endl << "*in_p_model: " << *in_p_model; ProModelitem ParameterModelItem_struct; if ( ParameterOwner_string_upper == "MODEL" ) isis::isis_ProMdlToModelitem ( *in_p_model, &ParameterModelItem_struct ); else isis::isis_ProModelitemByNameInit (*in_p_model, PRO_FEATURE, ParameterOwner_wchar, &ParameterModelItem_struct); ProParameter ProParameter_struct; isis::isis_ProParameterInit ( &ParameterModelItem_struct, ParameterName_wchar, &ProParameter_struct); ProParamvalue ProParamvalue_struct; isis::isis_ProParameterValueGet( &ProParameter_struct, &ProParamvalue_struct ); switch ( ProParamvalue_struct.type ) { case PRO_PARAM_DOUBLE: sprintf(ReadValue,"%lf", ProParamvalue_struct.value.d_val); break; case PRO_PARAM_STRING: char narrow_string[ISIS_CHAR_BUFFER_LENGTH]; ProWstringToString(narrow_string,ProParamvalue_struct.value.s_val); sprintf(ReadValue,"%s", narrow_string ); break; case PRO_PARAM_INTEGER: sprintf(ReadValue,"%d", ProParamvalue_struct.value.i_val); break; case PRO_PARAM_BOOLEAN: if ( ProParamvalue_struct.value.l_val == PRO_B_TRUE ) sprintf(ReadValue,"%s", "TRUE"); else sprintf(ReadValue,"%s", "FALSE"); break; default: std::string err_str = "exception : Erroneous CADReadParameter Type, Supported types are DOUBLE, INTEGER, STRING, and BOOLEAN."; isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << err_str; throw isis::application_exception(err_str); } } catch ( isis::application_exception& ex ) { std::string err_str = "exception : Part/Assembly Name: " + in_model_name + ", Parameter Name: " + in_ParameterName + ", " + ex.what(); throw isis::application_exception("C01005", err_str); } return std::string(ReadValue); } // end GetParametricParameter
ProError visit_component_action( ProFeature* in_feature, ProError in_status, Appdata in_app_data ) { ProError rs; ProMdl model; switch( rs = ProAsmcompMdlGet(in_feature, &model) ) { case PRO_TK_NO_ERROR: break; case PRO_TK_BAD_INPUTS: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "The specified feature is not a valid component feature."; return PRO_TK_GENERAL_ERROR; case PRO_TK_E_NOT_FOUND: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "Assembly component model is not a solid or is not in memory."; return PRO_TK_GENERAL_ERROR; default: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "unexpected error: " << rs; return PRO_TK_GENERAL_ERROR; } ProSolid solid = static_cast<ProSolid>(model); ProMdlType component_type; switch( rs = ProMdlTypeGet(model, &component_type) ) { case PRO_TK_NO_ERROR: break; case PRO_TK_BAD_INPUTS: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "The input argument is invalid."; return PRO_TK_GENERAL_ERROR; case PRO_TK_GENERAL_ERROR: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "The information could not be obtained."; return PRO_TK_GENERAL_ERROR; default: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "unexpected error: " << rs; return PRO_TK_GENERAL_ERROR; } ProAsmcomp component = static_cast<ProAsmcomp>(*in_feature); Appdata app_data; app_data.level = in_app_data.level+1; app_data.path.owner = static_cast<ProSolid>(component.owner); app_data.path.owner = in_app_data.path.owner; app_data.path.table_num = in_app_data.path.table_num + 1; for( int ix=0; ix < app_data.path.table_num; ++ix ) { app_data.path.comp_id_table[ix] = in_app_data.path.comp_id_table[ix]; } app_data.path.comp_id_table[app_data.path.table_num] = in_feature->id; switch( component_type ) { case PRO_ASSEMBLY: { ProAppData* app_data_vp = reinterpret_cast<ProAppData*>(&app_data); switch( rs = ProSolidFeatVisit(solid, visit_action, filter_action, app_data_vp) ) { case PRO_TK_NO_ERROR: break; case PRO_TK_E_NOT_FOUND: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "filter produced no component features."; break; default: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "Any other value is the value returned " << " by the action function (visiting stopped)." << rs; } } break; case PRO_PART: { ProMdl self; switch( rs = ProModelitemMdlGet(in_feature, &self) ) { case PRO_TK_NO_ERROR: break; case PRO_TK_BAD_INPUTS: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "feature has no model. " << in_feature->id; } char assembly_name[PRO_NAME_SIZE]; { ProName wname; switch( rs = ProMdlNameGet(self, wname) ) { case PRO_TK_NO_ERROR: break; case PRO_TK_BAD_INPUTS: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "The input argument is invalid. " << in_feature->id; throw std::runtime_error("selector feature name failed"); case PRO_TK_E_NOT_FOUND: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "The specified item does not have a name. "; break; default: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "ill specified error: " << rs; throw std::runtime_error("selector feature name failed"); } ProWstringToString(assembly_name, wname); } char model_name[PRO_PATH_SIZE]; { wchar_t* wname; ProBoolean is_modifiable; switch( rs = ProMdlCommonnameGet(self, &wname, &is_modifiable) ) { case PRO_TK_NO_ERROR: break; case PRO_TK_BAD_INPUTS: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "The input argument is invalid. " << in_feature->id; throw std::runtime_error("selector feature name failed"); case PRO_TK_E_NOT_FOUND: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "The specified item does not have a name. "; break; default: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "ill specified error: " << rs; throw std::runtime_error("selector feature name failed"); } ProWstringToString(model_name, wname); ProWstringFree(wname); } char item_name[PRO_NAME_SIZE]; { ProName wname; switch( rs = ProModelitemNameGet(in_feature, wname) ) { case PRO_TK_NO_ERROR: break; case PRO_TK_BAD_INPUTS: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "The input argument is invalid. " << in_feature->id; throw std::runtime_error("selector feature name failed"); case PRO_TK_E_NOT_FOUND: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "The specified item does not have a name. "; break; default: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "ill specified error: " << rs; throw std::runtime_error("selector feature name failed"); } ProWstringToString(item_name, wname); } // If you request the transformation from the member to the // assembly, this is PRO_B_TRUE. Otherwise, this is PRO_B_FALSE. ProBoolean bottom_up = PRO_B_TRUE; ProMatrix transformation; // retrieve the transformation matrix, given the component path. switch( rs = ProAsmcomppathTrfGet(&app_data.path, bottom_up, transformation) ) { case PRO_TK_NO_ERROR: break; case PRO_TK_BAD_INPUTS: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "transform get, the input argument is invalid: " << app_data.path.comp_id_table; return PRO_TK_GENERAL_ERROR; case PRO_TK_GENERAL_ERROR: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "The specified component path was wrong, or contained missing members."; return PRO_TK_GENERAL_ERROR; default: isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "unexpected error: " << rs; return PRO_TK_GENERAL_ERROR; } isis_LOG(lg, isis_FILE, isis_INFO) << "transformation: " << assembly_name << " : " << model_name << " : " << item_name; isis_LOG(lg, isis_FILE, isis_INFO) << "["; for( int ix=0; ix < 4; ++ix ) { isis_LOG(lg, isis_FILE, isis_INFO) << "\n\t["; for( int jx=0; jx < 4; ++jx ) { isis_LOG(lg, isis_FILE, isis_INFO) << '\t' << transformation[ix][jx]; } isis_LOG(lg, isis_FILE, isis_INFO) << "]"; } isis_LOG(lg, isis_FILE, isis_INFO) << "]\n"; return PRO_TK_NO_ERROR; } default: { isis_LOG(lg, isis_CONSOLE_FILE, isis_ERROR) << "unknown-component-type: " << component_type; } } return PRO_TK_NO_ERROR; }
/*---------------------------------------------------------------------*\ Populate appdata Example Code: C:\Program Files\PTC\Creo 2.0\Common Files\M070\protoolkit\protk_appls\pt_userguide\ptu_asm\UgAsmCompVisit.c \*---------------------------------------------------------------------*/ ProError user_action( ProFeature *feature, ProError status, ProAppData appdata) { ProMdl mdl; char name[PRO_NAME_SIZE]; char type[PRO_TYPE_SIZE]; // wchar_t wname[PRO_NAME_SIZE]; UserAppdata *appd; ProMdldata mdldata; appd = (UserAppdata *)appdata; try { isis::isis_ProAsmcompMdlGet(feature , &mdl); } catch(...) { log4cpp::Category& logcat_fileonly = log4cpp::Category::getInstance(LOGCAT_LOGFILEONLY); // Call again to get the error code ProError proError_temp = ProAsmcompMdlGet(feature , &mdl); // PRO_TK_E_NOT_FOUND - Assembly component model is not a solid or is not in memory. // It would not be in memory because it was not pulled in as a simplified rep if ( proError_temp == PRO_TK_E_NOT_FOUND ) { //std::cout << std::endl << std::endl << "@@@@@@@@@@@@@@@@@@@@@ isis_ProAsmcompMdlGet @@@@@@@@@@@@@@@@@@@@@@@@@@@@"; logcat_fileonly.errorStream() << "INFORMATION: isis_ProAsmcompMdlGet(feature , &mdl), Could not retrieve sub-part/assembly, probably because the simplified rep did not contain the part/assembly"; logcat_fileonly.errorStream() << "isis_ProAsmcompMdlGet(feature , &mdl), feature: " << feature; logcat_fileonly.errorStream() << " id " << feature->id; logcat_fileonly.errorStream() << " owner " << feature->owner; logcat_fileonly.errorStream() << " type " << feature->type; return(PRO_TK_CONTINUE); } else { logcat_fileonly.errorStream() << "isis_ProAsmcompMdlGet(feature , &mdl), feature: " << feature; logcat_fileonly.errorStream() << " id " << feature->id; logcat_fileonly.errorStream() << " owner " << feature->owner; logcat_fileonly.errorStream() << " type " << feature->type; throw; } } isis::isis_ProMdlDataGet(mdl, &mdldata); ProWstringToString(name,mdldata.name); ProWstringToString(type,mdldata.type); CreoModelAssemblyAttributes modelAttributes; if ( strncmp(type,"ASM",3) == 0 ) modelAttributes.modelType = PRO_MDL_ASSEMBLY; else modelAttributes.modelType = PRO_MDL_PART; modelAttributes.modelname = mdldata.name; modelAttributes.p_solid_handle = (ProSolid)mdl; modelAttributes.proAsmcomp = *feature; if ( appd->assemblyHierarchy.includeTheEntireHierarchy && strncmp(type,"ASM",3) == 0) { UserAppdata appdata_temp(modelAttributes); appdata_temp.assemblyHierarchy.includeTheEntireHierarchy = true; isis::isis_ProSolidFeatVisit((ProSolid)mdl, user_action, UserAsmCompFilter, &appdata_temp); } appd->assemblyHierarchy.children.push_back(modelAttributes); if (feature != NULL) return(PRO_TK_NO_ERROR); return(PRO_TK_CONTINUE); }
/*============================================================================*\ Function: ProUtilMenuStringManySelect Purpose: Select many string from menu with submenu Select All/Unsell All \*============================================================================*/ ProError ProUtilMenuStringManySelect( char *menu_name, /* In : Menu name */ wchar_t **w_menu_buttons, /* In : Menu buttons */ int **output_array, /* Out: ProArray of numbers of selected strings, use ProArrayFree to free memory */ int *p_n_sel) /* Out: Number of selected components */ { int i, n_but, n_sel, menu_id, action; ProError err, ret_status = PRO_TK_USER_ABORT; int *toggle_array; MenuToggleInfo toggle_info; ProCharName name; wchar_t **w_menus; for(n_but=0; w_menu_buttons[n_but][0] != '\0'; n_but++); err = ProArrayAlloc(n_but, sizeof(int), 1, (ProArray*)&toggle_array); toggle_info.w_menu_buttons = w_menu_buttons; toggle_info.button_status = toggle_array; toggle_info.n_buttons = n_but; toggle_info.menu_name = menu_name; err = ProMenuFromStringsRegister ( menu_name, NULL, w_menu_buttons, NULL, NULL, &menu_id); for (i=0; i<n_but; i++) { toggle_array[i] = 0; ProWstringToString(name, w_menu_buttons[i]); err = ProMenubuttonActionSet(menu_name, name, (ProMenubuttonAction)ProUtilMenuToggleOne, &toggle_info, i); } err = ProMenubuttonActionSet(menu_name, menu_name, (ProMenubuttonAction)ProMenuDelete, NULL, 0); err = ProMenuModeSet(menu_name, PROMENUMODE_DATA); err = ProMenuDatamodeSet(menu_name, PRO_B_TRUE ); err = ProMenuCreate(PROMENUTYPE_MAIN, menu_name, &menu_id); err = ProUtilMenuStringsAlloc(&w_menus); err = ProUtilMenuStringsStrAdd(&w_menus, (char *)"Select All"); err = ProUtilMenuStringsStrAdd(&w_menus, (char *)"Unsel All"); err = ProUtilMenuStringsStrAdd(&w_menus, (char *)"Done Sel"); err = ProUtilMenuStringsStrAdd(&w_menus, (char *)"Quit Sel"); ProMenuFromStringsRegister ( (char *)"TkMenuUtilSelect", NULL, w_menus, NULL, NULL, &menu_id); err = ProMenubuttonActionSet((char *)"TkMenuUtilSelect", (char *)"Select All", (ProMenubuttonAction)ProUtilMenuToggleDone, &toggle_info, SELECT_ALL); err = ProMenubuttonActionSet((char *)"TkMenuUtilSelect", (char *)"Unsel All", (ProMenubuttonAction)ProUtilMenuToggleDone, &toggle_info, UNSEL_ALL); err = ProMenubuttonActionSet((char *)"TkMenuUtilSelect", (char *)"Done Sel", (ProMenubuttonAction)ProUtilMenuToggleDone, &toggle_info, DONE_SEL); err = ProMenubuttonActionSet((char *)"TkMenuUtilSelect", (char *)"Quit Sel", (ProMenubuttonAction)ProUtilMenuToggleDone, &toggle_info, QUIT_SEL); err = ProMenubuttonActionSet((char *)"TkMenuUtilSelect", (char *)"TkMenuUtilSelect", (ProMenubuttonAction)ProUtilMenuToggleDone, &toggle_info, QUIT_SEL); err = ProMenuCreate(PROMENUTYPE_SUB, (char *)"TkMenuUtilSelect", &menu_id); err = ProMenuProcess((char *)"TkMenuUtilSelect", &action); if(err == PRO_TK_NO_ERROR && action == DONE_SEL) { err = ProArrayAlloc(0, sizeof(int), 1, (ProArray*)output_array); n_sel = 0; for (i=0; i<n_but; i++) if (toggle_array[i]) { ProArrayObjectAdd((ProArray*)output_array, PRO_VALUE_UNUSED, 1, &i); n_sel++; } if (n_sel>0) { *p_n_sel = n_sel; ret_status = PRO_TK_NO_ERROR; } else err = ProArrayFree((ProArray*)output_array); } err = ProArrayFree((ProArray*)&toggle_array); return (ret_status); }
/*====================================================================*\ FUNCTION : ProUtilElemPrint() PURPOSE : Visit function. \*====================================================================*/ ProError ProUtilElemPrint( ProElement elem_tree, ProElement elem, ProElempath elem_path, FeatureElemPrintData* p_data ) { ProError status; ProElemId elem_id; int dimension_id = -1; ProBoolean is_visible; ProBoolean is_incomplete; ProBoolean is_compound; ProBoolean is_array; ProBoolean is_multival; ProValue* p_values; ProValue value; int array_size; ProValueData value_data; char value_data_str[ 48 ]; int i; ProBoolean flag = PRO_B_TRUE; status = ProElementIdGet( elem, &elem_id ); TEST_CALL_REPORT("ProElementIdGet()", "ProUtilElemPrint()", PRO_TK_NO_ERROR, status != PRO_TK_NO_ERROR); ProTKFprintf( p_data->fp, "Element ID: %d\n", elem_id ); status = ProFeatureElemIsVisible( p_data->p_feature, elem_path, &is_visible ); #if 0 TEST_CALL_REPORT("ProFeatureElemIsVisible()", "ProUtilElemPrint()", status, status != PRO_TK_NO_ERROR ); #else /* This function return PRO_TK_E_NOT_FOUND for Element FEATURE_TYPE, from feature PRO_FEAT_DATUM_QUILT (it's a bug)*/ TEST_CALL_REPORT("ProFeatureElemIsVisible()", "ProUtilElemPrint()", status, 0); #endif status = ProFeatureElemIsIncomplete( p_data->p_feature, elem_path, &is_incomplete ); #if 0 /* spr 751801 */ TEST_CALL_REPORT( "ProFeatureElemIsIncomplete()", "ProUtilElemPrint()", status, status != PRO_TK_NO_ERROR); #else TEST_CALL_REPORT( "ProFeatureElemIsIncomplete()", "ProUtilElemPrint()", status, 0 ); #endif status = ProElementIsCompound( elem, NULL, &is_compound ); TEST_CALL_REPORT("ProElementIsCompound()", "ProUtilElemPrint()", status, status != PRO_TK_NO_ERROR); status = ProElementIsArray(elem, NULL, &is_array ); TEST_CALL_REPORT("ProElementIsArray()", "ProUtilElemPrint()", status, status != PRO_TK_NO_ERROR); ProTKFprintf( p_data->fp, is_visible == PRO_B_TRUE ? "\tVisible\n" : "\tInvisible\n" ); ProTKFprintf( p_data->fp, is_incomplete == PRO_B_TRUE ? "\tIncomplete\n" : "\tComplete\n" ); ProTKFprintf( p_data->fp, is_compound == PRO_B_TRUE ? "\tCompound\n" : (is_array == PRO_B_TRUE ? "\tArray\n" : "\tNeither compound nor array\n")); if( is_compound == PRO_B_TRUE || is_array == PRO_B_TRUE) return PRO_TK_NO_ERROR; status = ProFeatureElemDimensionIdGet( p_data->p_feature, elem_path, &dimension_id ); TEST_CALL_REPORT("ProFeatureElemDimensionIdGet()", "ProUtilElemPrint()", status, (status != PRO_TK_NO_ERROR)&& (status != PRO_TK_E_NOT_FOUND)); if (status != PRO_TK_E_NOT_FOUND) ProTKFprintf( p_data->fp, "\tDimension ID: %d\n", dimension_id ); else ProTKFprintf( p_data->fp, "\tThis element does not contain dimension\n"); status = ProArrayAlloc( 0, sizeof(ProValue), 1, (ProArray*)&p_values ); TEST_CALL_REPORT( "ProArrayAlloc()", "ProUtilElemPrint()", status, status != PRO_TK_NO_ERROR ); status = ProElementIsMultival(elem, NULL, &is_multival); TEST_CALL_REPORT( "ProElementIsMultival", "ProUtilElemPrint", status, status != PRO_TK_NO_ERROR); if (is_multival == PRO_B_TRUE) { status = ProFeatureElemValuesGet( p_data->p_feature, elem_path, &p_values ); #if 0 TEST_CALL_REPORT( "ProFeatureElemValuesGet()", "ProUtilElemPrint()", status, status != PRO_TK_NO_ERROR ); #else /* ProFeatureElemValuesGet() - returns PRO_TK_E_NOT_FOUND in the PIPE mode for Element PRO_E_STD_EDGE_CHAMF_EDGES.(bugminsk1347)*/ TEST_CALL_REPORT( "ProFeatureElemValuesGet()", "ProUtilElemPrint()", status, 0 ); #endif } else { status = ProElementValueGet(elem, &value); TEST_CALL_REPORT( "ProElementValueGet", "ProUtilElemPrint", status, status != PRO_TK_NO_ERROR); status = ProArrayObjectAdd((ProArray*)&p_values, PRO_VALUE_UNUSED, 1, &value); TEST_CALL_REPORT( "ProArrayObjectAdd", "ProUtilElemPrint", status, status != PRO_TK_NO_ERROR); } if (p_values!=NULL){ array_size = 0; status = ProArraySizeGet( (ProArray)p_values, &array_size ); TEST_CALL_REPORT( "ProArraySizeGet()", "ProUtilElemPrint()", status, status != PRO_TK_NO_ERROR ); ProTKFprintf( p_data->fp, "\t%s\n",(i=1)?"Value:":"Values:" ); for( i=0; i<array_size; i++ ) { /*To avoid PRO_E_SKETCHER and PRO_E_PATTERN, following condition is set*/ if(( elem_id == 458) || (elem_id == 27)) flag = PRO_B_FALSE; if(flag == PRO_B_TRUE) { status = ProValueDataGet( p_values[i], &value_data ); TEST_CALL_REPORT( "ProValueDataGet()", "ProUtilElemPrint()", status, status != PRO_TK_NO_ERROR ); switch( value_data.type ) { case PRO_VALUE_TYPE_INT: ProTKSprintf( value_data_str, "%d", value_data.v.i ); break; case PRO_VALUE_TYPE_DOUBLE: ProTKSprintf( value_data_str, "%f", value_data.v.d ); break; case PRO_VALUE_TYPE_POINTER: ProTKSprintf( value_data_str, "Pointer=*", value_data.v.p ); break; case PRO_VALUE_TYPE_STRING: if ( value_data.v.s !=NULL) ProTKSprintf( value_data_str, "%s", value_data.v.s ); else ProTKSprintf( value_data_str,"<NULL>" ); break; case PRO_VALUE_TYPE_WSTRING: /* NOTE - NULL is possible in some element trees (for example, for the element PRO_E_STD_FEATURE_NAME where NULL means that feature has the default name) */ if ( value_data.v.w !=NULL) ProWstringToString( value_data_str, value_data.v.w ); else ProTKSprintf( value_data_str,"<NULL>" ); break; case PRO_VALUE_TYPE_SELECTION: ProTKSprintf( value_data_str, "Selection" ); break; case PRO_VALUE_TYPE_TRANSFORM: ProTKSprintf( value_data_str, "Transformation" ); break; default: ProTKSprintf( value_data_str, "**UNKNOWN**\n" ); } ProTKFprintf( p_data->fp, "\t%s\n", value_data_str ); } } status = ProArrayFree( (ProArray*)&p_values ); TEST_CALL_REPORT( "ProArrayFree()", "ProUtilFeatureElementsDump()", status, status != PRO_TK_NO_ERROR ); } return PRO_TK_NO_ERROR; }
// Description: // Set in_MaterialName material properties to be the same as the current material (i.e. material that // is set to current in the Creo Model) // // Pre-Conditions: // in_Part must be a model retrieved into memory. // in_MaterialName length < 32 chars // // Post-Conditions // if in_MaterialName is already the current material // return; // no action required. // else // if in_MaterialName material does not exist // throw isis::application_exception // else // set in_MaterialName properties to be equal to the current material properties //////////////////////////////////////////////////////////////////////////////////////////////////////// void SetMaterialPropertiesToBeTheSameAsCurrentMaterial(ProSolid in_part, const std::string &in_MaterialName ) throw (isis::application_exception) { // Check if material exist if ( !MaterialExists(in_part, in_MaterialName) ) { std::string TempError = "Function SetMaterialPropertiesToBeTheSameAsCurrentMaterial(...) was passed a material name that does not exist in the model (i.e. argument in_part). in_MaterialName: " + in_MaterialName; throw isis::application_exception(TempError.c_str()); } // Get current material ProMaterial currentMaterial; isis::isis_ProMaterialCurrentGet( in_part, ¤tMaterial ); ProModelitem currentMaterialModelItem; isis_ProModelitemByNameInit ( in_part, PRO_RP_MATERIAL, currentMaterial.matl_name, ¤tMaterialModelItem ); // Check if in_MaterialName is the current material, if so, no action required. char stringBuffer[PRO_NAME_SIZE]; // PRO_NAME_SIZE = 32 ProWstringToString(stringBuffer, currentMaterial.matl_name); std::string tempString = isis::ConvertToUpperCase(in_MaterialName); if ( strcmp(tempString.c_str(), _strupr(stringBuffer )) == 0 ) { // The current material is in_MaterialName. No action needed. return; } // Destination material ProMaterial destinationMaterial; ProName materialName_wchar; ProStringToWstring(materialName_wchar, (char *)in_MaterialName.c_str() ); ProModelitem destinationMaterialModelItem; isis_ProModelitemByNameInit ( in_part, PRO_RP_MATERIAL, materialName_wchar, &destinationMaterialModelItem ); // Copy the material properties from the current to destination material property ProParamvalue materialValue; ProUnititem materialUnit; // Density isis::isis_ProMaterialPropertyGet( ¤tMaterialModelItem, PRO_MATPROP_MASS_DENSITY, &materialValue, &materialUnit ); isis::isis_ProMaterialPropertySet( &destinationMaterialModelItem, PRO_MATPROP_MASS_DENSITY, &materialValue, &materialUnit ); // Poisson' Ratio isis::isis_ProMaterialPropertyGet( ¤tMaterialModelItem, PRO_MATPROP_POISSON_RATIO, &materialValue, &materialUnit ); isis::isis_ProMaterialPropertySet( &destinationMaterialModelItem, PRO_MATPROP_POISSON_RATIO, &materialValue, &materialUnit ); // Young's Modulus isis::isis_ProMaterialPropertyGet( ¤tMaterialModelItem, PRO_MATPROP_YOUNG_MODULUS, &materialValue, &materialUnit ); isis::isis_ProMaterialPropertySet( &destinationMaterialModelItem, PRO_MATPROP_YOUNG_MODULUS, &materialValue, &materialUnit ); // Coeef. of Thermal Expansion isis::isis_ProMaterialPropertyGet( ¤tMaterialModelItem, PRO_MATPROP_THERMAL_EXPANSION_COEFFICIENT, &materialValue, &materialUnit ); isis::isis_ProMaterialPropertySet( &destinationMaterialModelItem, PRO_MATPROP_THERMAL_EXPANSION_COEFFICIENT, &materialValue, &materialUnit ); // Stress-Strain Response e.g. Linear, Hyperelastic, Elastroplastic // Couldn't find the enum entry // Specific Heat Capicity isis::isis_ProMaterialPropertyGet( ¤tMaterialModelItem, PRO_MATPROP_SPECIFIC_HEAT, &materialValue, &materialUnit ); isis::isis_ProMaterialPropertySet( &destinationMaterialModelItem, PRO_MATPROP_SPECIFIC_HEAT, &materialValue, &materialUnit ); // Thermal Conductivity isis::isis_ProMaterialPropertyGet( ¤tMaterialModelItem, PRO_MATPROP_THERMAL_CONDUCTIVITY, &materialValue, &materialUnit ); isis::isis_ProMaterialPropertySet( &destinationMaterialModelItem, PRO_MATPROP_THERMAL_CONDUCTIVITY, &materialValue, &materialUnit ); // Symmetry e.g. isotropic // Could not find the enum entry try { // Don't fail if this doesnt't exist. // Initial Bend Y-Factor isis::isis_ProMaterialPropertyGet( ¤tMaterialModelItem, PRO_MATPROP_INITIAL_BEND_Y_FACTOR, &materialValue, &materialUnit ); isis::isis_ProMaterialPropertySet( &destinationMaterialModelItem, PRO_MATPROP_INITIAL_BEND_Y_FACTOR, &materialValue, &materialUnit ); } catch (...) { } // Bend Table, skip this //isis::isis_ProMaterialPropertyGet( ¤tMaterialModelItem, PRO_MATPROP_BEND_TABLE, &materialValue, &materialUnit ); //isis::isis_ProMaterialPropertySet( &destinationMaterialModelItem, PRO_MATPROP_BEND_TABLE, &materialValue, &materialUnit ); // Cross Hatching // Could not find the enum entry }
bool make_solid_templated( ProSolid& in_original, ProSolid& out_template ) { ProError rc; char pro_str[128]; log4cpp::Category& log_cf = log4cpp::Category::getInstance(LOGCAT_CONSOLEANDLOGFILE); ProUnitsystem original_system; switch( rc = ProMdlPrincipalunitsystemGet(in_original, &original_system) ) { case PRO_TK_NO_ERROR: break; case PRO_TK_BAD_INPUTS: log_cf.errorStream() << "failed getting the principal unit-system."; break; default: log_cf.errorStream() << "could not aquire the unit system = " << rc; return false; } /* ProUnititem* original_mass_unit; switch( rc = ProMdlUnitsCollect( in_original, PRO_UNITTYPE_MASS, &original_mass_unit) ) { case PRO_TK_NO_ERROR: break; default: log_cf.errorStream() << "could not collect unit systems = " << rc; return false; } */ ProUnitsystem* template_systems; //ProUnititem template_units; switch( rc = ProMdlUnitsystemsCollect( out_template, &template_systems) ) { case PRO_TK_NO_ERROR: break; default: log_cf.errorStream() << "could not collect unit systems = " << rc; return false; } ProUnitsystem template_system; int size_template_systems; ProArraySizeGet( template_systems, &size_template_systems ); for( int ix=0; ix < size_template_systems; ++ix ) { int names_matched; ProWstringCompare(template_systems[ix].name, original_system.name, PRO_VALUE_UNUSED, &names_matched); if (names_matched != 0) continue; template_system = template_systems[ix]; break; } switch( rc = ProMdlPrincipalunitsystemSet(out_template, &template_system, PRO_UNITCONVERT_SAME_SIZE, PRO_B_TRUE, PRO_VALUE_UNUSED) ) { case PRO_TK_NO_ERROR: break; case PRO_TK_BAD_INPUTS: log_cf.errorStream() << "could not set the units in the shrinkwrap : " << ProWstringToString(pro_str, template_system.name); break; default: log_cf.errorStream() << "could not set units in shinkwrap = " << rc; return false; } return true; }