/* Copyright (c) 2024 PTC Inc. and/or Its Subsidiary Companies. All Rights Reserved. */ /*------------------------------------------------------------------*\ Pro/Toolkit includes \*------------------------------------------------------------------*/ #include <ProToolkit.h> #include <ProObjects.h> #include <ProFeature.h> #include <ProDimension.h> #include <ProSolid.h> #include <ProUtil.h> #include <ProMessage.h> #include <PTApplsUnicodeUtils.h> /*------------------------------------------------------------------*\ Application includes \*------------------------------------------------------------------*/ #include <TestError.h> /*==================================================================*\ FUNCTION : UserDimDisplayRounded() PURPOSE : Change the displayed value of a selected model dimension to rounded/non-rounded. \*==================================================================*/ ProError UserDimDisplayRounded() { ProMdl model ; /* current model */ ProSelection *p_sel_feat ; /* selected feature */ ProSelection *p_sel_dim ; /* selected dimension */ ProModelitem dim_mdlitem ; /* dimension Modelitem */ int n_sel_feat = -1 ; /* no. of selected features */ int n_sel_dim = -1; /* no. of selected dims */ ProFileName msg_file ; /* message file */ int err ; /* return status */ double value; /* dimension value */ double newdimval ; /* user-entered dim value */ ProCharLine str1 ; /* message string */ ProBoolean display_rounded; /* rounded display status */ ProStringToWstring(msg_file, "msg_ugfund.txt") ; /*------------------------------------------------------------------*\ Check for a model. \*------------------------------------------------------------------*/ err = ProMdlCurrentGet(&model); ERROR_CHECK("UserDimDisplayRounded()", "ProMdlCurrentGet()", err); if (err != PRO_TK_NO_ERROR) { ProMessageDisplay(msg_file, "USER %0s F", "Error getting current model."); return(err) ; } /*------------------------------------------------------------------*\ Get a feature to modify. \*------------------------------------------------------------------*/ ProMessageDisplay(msg_file, "USER %0s F", "Select a feature."); err = ProSelect("feature", 1, NULL, NULL, NULL, NULL, &p_sel_feat, &n_sel_feat) ; ERROR_CHECK("UserDimDisplayRounded()", "ProSelect()", err); if ( err != PRO_TK_NO_ERROR || n_sel_feat < 1) { ProMessageDisplay(msg_file, "USER %0s F", "Error or abort during selection.") ; return(err) ; } ProSelectionUnhighlight (p_sel_feat [0]); /*------------------------------------------------------------------*\ Show the dimensions on the feature. \*------------------------------------------------------------------*/ err = ProFeatureParamsDisplay (p_sel_feat [0], PRO_DIM_PARAM); ERROR_CHECK ("UserDimDisplayRounded()", "ProFeatureParamsDisplay()", err); /*------------------------------------------------------------------*\ Get the dimension to be changed. \*------------------------------------------------------------------*/ ProMessageDisplay(msg_file, "USER %0s F", "Select a dimension."); err = ProSelect("dimension", 1, NULL, NULL, NULL, NULL, &p_sel_dim, &n_sel_dim) ; ERROR_CHECK("UserDimDisplayRounded()", "ProSelect()", err); if ( err != PRO_TK_NO_ERROR || n_sel_dim < 1) { ProMessageDisplay(msg_file, "USER %0s F", "Error or abort during selection.") ; return(err) ; } err = ProSelectionModelitemGet(p_sel_dim[0], &dim_mdlitem); ERROR_CHECK("UserDimDisplayRounded()", "ProSelectionModelitemGet()", err); err = ProDimensionIsDisplayRoundedValue(&dim_mdlitem, &display_rounded ); ERROR_CHECK("UserDimDisplayRounded()", "prodim_get_dimension()", err); /*------------------------------------------------------------------*\ Change the dimension. \*------------------------------------------------------------------*/ ProTKSprintf(str1, "Toggling the Display Rounded property.") ; ProMessageDisplay(msg_file, "USER %0s F", str1) ; err = ProDimensionDisplayRoundedValueSet ( &dim_mdlitem, !display_rounded); ERROR_CHECK("UserDimDisplayRounded()", "ProDimensionValueSet()", err); err = ProDimensionDisplayUpdate ( &dim_mdlitem ); ProMessageDisplay(msg_file, "USER %0s F", "Display Rounded property toggled."); return(PRO_TK_NO_ERROR) ; }