/* Copyright (c) 2024 PTC Inc. and/or Its Subsidiary Companies. All Rights Reserved. */ #include <ProToolkit.h> #include <ProSimprep.h> #include <ProSimprepdata.h> #include <ProSelection.h> #include <ProUtil.h> #include <ProSolid.h> #include <ProAsmcomp.h> #include <ProAsmcomppath.h> #include <ProModelitem.h> #include <TestError.h> #include <PTApplsUnicodeUtils.h> /*===========================================================*\ FUNCTION : UserSimpRepInfo PURPOSE : Prints out the simplified representation information. \*===========================================================*/ int UserSimpRepInfo () { ProMdl owner; ProSimprep simp_rep; ProSimprepdata *data; ProSimprepActionType def_act; wchar_t w_sr_name[PRO_LINE_SIZE]; char temp[PRO_LINE_SIZE] = ""; ProBoolean tmp_rep = PRO_B_FALSE; ProError status; int num = 0; ProError UserSimpRepVisAct(); status = ProMdlCurrentGet(&owner); ERROR_CHECK("UserSimpRepInfo","ProMdlCurrentGet",status); if (status != PRO_TK_NO_ERROR) return (status); status = ProSimprepSelect ((ProSolid)owner, &simp_rep); ERROR_CHECK("UserSimpRepInfo","ProSimprepSelect",status); if (status == PRO_TK_NO_ERROR && simp_rep.id != -1) { status = ProSimprepdataGet (&simp_rep, &data); ERROR_CHECK("UserSimpRepInfo","ProSimprepdataGet",status); if (status == PRO_TK_NO_ERROR) { status = ProSimprepdataNameGet (data, w_sr_name); ERROR_CHECK("UserSimpRepInfo","ProSimprepdataNameGet",status); if (status == PRO_TK_NO_ERROR) { pro_wstr_to_str (temp, w_sr_name); ProTKPrintf ("Simp rep name : %s\n", temp); } status = ProSimprepdataDefltGet (data, &def_act); ERROR_CHECK("UserSimpRepInfo","ProSimprepdataDefltGet",status); if (status == PRO_TK_NO_ERROR) { switch (def_act) { case PRO_SIMPREP_NONE: strcpy (temp, "None"); break; case PRO_SIMPREP_REVERSE: strcpy (temp, "Reverse"); break; case PRO_SIMPREP_SUBSTITUTE: strcpy (temp, "Substitute"); break; case PRO_SIMPREP_INCLUDE: strcpy (temp, "Include"); break; case PRO_SIMPREP_EXCLUDE: strcpy (temp, "Exclude"); break; default: strcpy (temp, "Unknown"); } ProTKPrintf ("Default action : %s\n", temp); } status = ProSimprepdataTmpvalGet (data, &tmp_rep); ERROR_CHECK("UserSimpRepInfo","ProSimprepdataTmpvalGet",status); if (status == PRO_TK_NO_ERROR) { ProTKPrintf ("Temporary simp rep : %s\n", tmp_rep == PRO_B_TRUE ? "Yes" : "No"); } ProSimprepdataitemsVisit (data, NULL, UserSimpRepVisAct, (ProAppData) owner); ERROR_CHECK("UserSimpRepInfo","ProSimprepdataitemsVisit",status); status = ProSimprepdataFree (&data); } } return status; } /*===========================================================*\ FUNCTION : UserSimpRepVisAct PURPOSE : Highlights the members of the simplified representation. \*===========================================================*/ ProError UserSimpRepVisAct ( ProSimprepitem *item, ProError err, ProSolid owner) { ProError status; ProSelection selection; ProAsmcomppath comp_path; ProModelitem mdl_item; ProFeature feature; ProMdl model; ProMdlType mdl_type; int id; if (item->item_path.path_size != -1) { /*-----------------------------------------------------------*\ Part \*-----------------------------------------------------------*/ status = ProAsmcomppathInit (owner, item->item_path.comp_path, item->item_path.path_size, &comp_path); ERROR_CHECK("UserSimpRepVisAct","ProAsmcomppathInit",status); if (status == PRO_TK_NO_ERROR) { status = ProAsmcomppathMdlGet (&comp_path, &model); ERROR_CHECK("UserSimpRepVisAct","ProAsmcompMdlGet",status); } if (status == PRO_TK_NO_ERROR) { status = ProMdlIdGet(model, &id); ERROR_CHECK("UserSimpRepVisAct","ProMdlIdGet",status); status = ProMdlTypeGet(model, &mdl_type); ERROR_CHECK("UserSimpRepVisAct","ProMdlIdGet",status); if (status == PRO_TK_NO_ERROR) { status = ProModelitemInit (model, id, (ProType)mdl_type, &mdl_item); ERROR_CHECK("UserSimpRepVisAct","ProModelitemInit",status); } if (status == PRO_TK_NO_ERROR) { status = ProSelectionAlloc(&comp_path, &mdl_item, &selection); ERROR_CHECK("UserSimpRepVisAct","ProSelectionAlloc",status); } } } else { /*-----------------------------------------------------------*\ Feature \*-----------------------------------------------------------*/ status = ProFeatureInit (owner, item->item_path.feat_id, &feature); ERROR_CHECK("UserSimpRepVisAct","ProFeatureInit",status); if (status == PRO_TK_NO_ERROR) { status = ProFeatureSelectionGet (&feature, &selection); ERROR_CHECK("UserSimpRepVisAct","ProFeatureSelectionGet",status); } } if (status == PRO_TK_NO_ERROR) { ProSelectionHighlight (selection, PRO_COLOR_WARNING); ERROR_CHECK("UserSimpRepVisAct","ProSelectionHighlight",status); } return PRO_TK_NO_ERROR; }