Macro Changes Decimal To Fraction

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.

Reply to
inthepickle
Loading thread data ...

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

Reply to
Tin Man

I really appreciate the help. It worked like a charm.

Reply to
inthepickle

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.