I need help in a big way people. I need to find a macro that will check and see if the document properties is a decimal. If not, it will change it to fractions rounded to 1/16. Does anyone know of such a thing. Or how to go about programming this. I am not a Solidworks newbie, but I am not a programmer. Any help that you can give would be greatly appreciated.
Macro Changes Decimal To Fraction
May 11, 2005
2 Replies
So if the document properties are *not* set to decimal then change them to fraction? Are you sure about that?
The below macro will toggle between decimal and rounding fractions to the nearest 1/16th.
Hope it helps, Ken
Option Explicit Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2
Sub main() Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc
If swModel.GetUserPreferenceIntegerValue(swUnitsLinearDecimalDisplay) = swFRACTION Then swModel.SetUserPreferenceIntegerValue (swUnitsLinearDecimalDisplay), swDECIMAL Else swModel.SetUserPreferenceIntegerValue (swUnitsLinearDecimalDisplay), swFRACTION swModel.SetUserPreferenceIntegerValue (swUnitsLinearFractionDenominator), 16 swModel.SetUserPreferenceIntegerValue (swUnitsLinearRoundToNearestFraction), True End If
swModel.GraphicsRedraw2 End Sub
I really appreciate the help. It worked like a charm.
Join the Discussion
Have something to add? Share your thoughts — no account required.
Didn't find your answer?
Ask the community — no account required