Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

MACRO UNITS AND FONT

Status
Not open for further replies.

sfaz

Industrial
Jun 22, 2011
8
0
0
US
Hello, i need a macro to change some settings , like units, font size, arrow size etc. i copied this macro from a thread and it worked great i tried to add mass units property but i didnt have any success( i wrote what i thought was logic (i don't know anything about writing programs).

is there a list of codes for document settings and their values that i can check so i can just add to my macro. example the code for units is swUnitsLinear and values are swINCHES, swCM etc etc.

so i dont have to keep asking everytime i want to add a new setting to the macro


Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Sub main()

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc
Set SelMgr = Part.SelectionManager

Part.SetUserPreferenceToggle swDetailingDualDimensions, True
Part.SetUserPreferenceToggle swDetailingShowDualDimensionUnits, True
Part.SetUserPreferenceIntegerValue swDetailingDualDimPosition, swDualDimensionsOnBottom
Part.SetUserPreferenceIntegerValue swUnitsLinear, swINCHES
Part.SetUserPreferenceIntegerValue swUnitsLinearDecimalPlaces, 3
Part.SetUserPreferenceIntegerValue swUnitsAngularDecimalPlaces, 2
Part.SetUserPreferenceIntegerValue swUnitsDualLinear, swCM
Part.SetUserPreferenceIntegerValue swUnitsDualLinearDecimalPlaces, 2
Part.SetUserPreferenceIntegerValue swUnitsMass, swKG <-------------
End Sub

ok
thanks in advance
 
Replies continue below

Recommended for you

GREAT thx a lot TheTick o dont understand like 99.9% of the stuff in the API HELP but i manage to make mass units work.

sry its kind of obvious that i should have google SW API help but this morning i didnt even knew what API meant

Part.SetUserPreferenceIntegerValue swUnitsMassPropMass, swUnitsMassPropMass_Kilograms (dont know if it is the correct way to do it but its working :D)

ill keep digging into the API HELP section , to see what else i can change with a SINGLE CLICK :D

CADflyer havent really look into that feature, but now i will.

thank you for quick reply.
and no , never too early.
 
hello again and having a problem with this command

Part.SetUserPreferenceIntegerValue swDetailingDualDimPosition, swDualDimensionsOnBottom

the option changes to bottom , but the dimension stays on top. i have to open options and reclick the option "bottom" then click ok for the dual dimension to change.

anyone?
:S
 
I was able to repeat your observation. That line does cause the corresponding radio button in the document property page to be selected but it does not appear to have an effect. Saving and reopening the drawing as well as toggling the dual display of individual dimensions does not cause them to switch from top to bottom.

It looks like a bug to me. If you are using the current version, it should probably be reported. I am on 2009.

Eric
 
Status
Not open for further replies.
Back
Top