Modifying unit system with macro
Modifying unit system with macro
(OP)
CODE
Private sub main()
Dim swApp As SldWorks.SldWorks
Dim swDoc As ModelDoc2
Set swApp = Application.SldWorks
Set swDoc = swApp.ActiveDoc
'3 is the const value for IPS
swDoc.SetUserPreferenceIntegerValue swUnitSystem, 3
End sub
Dim swApp As SldWorks.SldWorks
Dim swDoc As ModelDoc2
Set swApp = Application.SldWorks
Set swDoc = swApp.ActiveDoc
'3 is the const value for IPS
swDoc.SetUserPreferenceIntegerValue swUnitSystem, 3
End sub
My default unit system is MMGS. When I run this macro and go into Tools-->Options-->Units it does have IPS selected. But the units in the document don't actually change---its still in MMGS.
Likewise, this does nothing either:
swDoc.SetUserPreferenceToggle swUnitSystem_IPS, True
What am I doing wrong? Thanks.






RE: Modifying unit system with macro
But you can change each of the units individually (i.e. Length, Alt Units Length, Angular Units, Mass, etc.)
This will get your document units switched to inches.
CODE
RE: Modifying unit system with macro
RE: Modifying unit system with macro
Here is what my .ini looks like:
CODE
[UNITS]
"Inch (Decimal 2)", 3, 1, 2
"Inch (Decimal 4)", 3, 1, 3
"Inch (Fraction)", 3, 2, 32
"Millimeter (decimal 2)", 0, 0, 2
Download the macro here: http
Flores