Macro Changes Decimal To Fraction

Discussion in 'SolidWorks' started by inthepickle, May 11, 2005.

  1. inthepickle

    inthepickle Guest

    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.
     
    inthepickle, May 11, 2005
    #1
  2. inthepickle

    Tin Man Guest

    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
     
    Tin Man, May 12, 2005
    #2
  3. inthepickle

    inthepickle Guest

    I really appreciate the help. It worked like a charm.
     
    inthepickle, May 12, 2005
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.