×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Looking for a simple macro

Looking for a simple macro

Looking for a simple macro

(OP)
I'm looking for a macro that will change a decimal dimension to a rounded 64th fraction. I tried recording my own macro but it does not work.
Here is what I'm looking for, I would select one or several dimensions that are in decimal format, then run the macro and they all are updated to a rounded nearest 64th
Any suggestions
Tom

Tom Malinski
Sr Design Engineer
OKay Industries
New Britain CT

RE: Looking for a simple macro

I assume your document units are set up to be decimal inches.  This should do what you want it to.  For each dim selected, if it is "Use Document Units" (I assume decimal display) it will change it to fraction with a 64ths base.  If it is not "Use Document Units", it will change back to Document Units.   If you need to tweak it, check the API help on DisplayDimension::SetUnits.

This code is very similar to code I posted fairly recently to toggle jogged ordinate dimensions.  It just toggles document unit display rather than jogged ordiante.

CODE

Dim swApp As SldWorks.SldWorks
Dim swDoc As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swDispDim As SldWorks.DisplayDimension
Dim i As Long

Sub FractionToggleMulti()
Set swApp = Application.SldWorks
Set swDoc = swApp.ActiveDoc
Set swSelMgr = swDoc.SelectionManager

For i = 1 To swSelMgr.GetSelectedObjectCount
    If swSelMgr.GetSelectedObjectType3(i, Empty) = swSelDIMENSIONS Then
        Set swDispDim = swSelMgr.GetSelectedObject6(i, Empty)
        If swDispDim.GetUseDocUnits Then
            swDispDim.SetUnits False, swINCHES, swFRACTION, 64, True
        Else
            swDispDim.SetUnits True, Empty, Empty, Empty, Empty
        End If
    End If
Next

'swDoc.ClearSelection2 True
'^^^Optional line - un-comment to de-select dims automatically

swDoc.GraphicsRedraw2
End Sub

RE: Looking for a simple macro

Just an FYI, a dimension favorite would have done this also.  Pick all the dims you want to change, then pick the dim favorite.

Just a reminder, right-click a dimension > properties > units.  Pick fractions and enter 64 as the denominator and check "round to nearest fraction".  Save this new dim as a favorite.  

SW07 SP2.0

Flores

RE: Looking for a simple macro

(OP)
Thanks so much, this works great
Tom

Tom Malinski
Sr Design Engineer
OKay Industries
New Britain CT

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources