change unit without go to tools-options

Feb 05, 2008 5 Replies

does anyone know how to change the unit from "mm" to "inch" or from "inch" to "mm" without go to tools-options? Thanks! ~m


Not that much help, but - the Grid button at least gets you into the document properties tab of tools-options in a single click, then it's just one more click to the units section. Maybe somebody has a macro that will help you (if not, maybe I'll write one when I have some free time, because it'd be useful for me too)...

handleman posted a macro on 27 Aug 07 at

formatting link
Sub DocUnitToggle()

Dim swApp As SldWorks.SldWorks Dim swDoc As SldWorks.ModelDoc2 Dim CurUnits As Integer

Set swApp =3D Application.SldWorks Set swDoc =3D swApp.ActiveDoc

CurUnits =3D swDoc.GetUserPreferenceIntegerValue(swUnitsLinear)

If CurUnits =3D swMM Then swDoc.SetUserPreferenceIntegerValue swUnitsLinear, swINCHES ElseIf CurUnits =3D swINCHES Then swDoc.SetUserPreferenceIntegerValue swUnitsLinear, swMM End If

End Sub

Thank you so much! very handy! :-)

at

formatting link
I have a similar situation. I created a bunch of part models in a template setup with metric units. I'm now creating drawings but the company has decided that the drawings are to be in imperial units. My drawing template is setup to display pounds but the value it pulls from the model is a kg value. Example, a part which has a mass of 3.2 kg shows on the imperial drawing template as weighing 3.2 pounds. There does not seem to be a way to pull the mass units in and even if there was I don't want kg on my imperial template.

The obvious solution to this is to go through each part file and change the mass units from kg to pounds before I make the drawing. Is there a macro to toggle the mass units or can someone think of a more elegant solution?

Modification of the above macro...I'm just cutting and pasting, I don't have access to a SW computer right now so I haven't tested it, correct me if I'm wrong.

-Mark

Sub DocUnitToggle()

Dim swApp As SldWorks.SldWorks Dim swDoc As SldWorks.ModelDoc2 Dim CurUnits As Integer

Set swApp =3D Application.SldWorks Set swDoc =3D swApp.ActiveDoc

CurUnits =3D swDoc.GetUserPreferenceIntegerValue(swUnitsMassPropMass)

If CurUnits =3D swUnitsMassPropMass_Kilograms Then swDoc.SetUserPreferenceIntegerValue swUnitsMassPropMass, swUnitsMassPropMass_Pounds ElseIf CurUnits =3D swUnitsMassPropMass_Pounds Then swDoc.SetUserPreferenceIntegerValue swUnitsMassPropMass, swUnitsMassPropMass_Kilograms End If

End sub

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required