×
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

MACRO UNITS AND FONT

MACRO UNITS AND FONT

MACRO UNITS AND FONT

(OP)
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
 

RE: MACRO UNITS AND FONT

Is it too early to asked if you have checked the SW API help?

RE: MACRO UNITS AND FONT

Have you looked into Design Checker feature for this function?

RE: MACRO UNITS AND FONT

(OP)
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.

RE: MACRO UNITS AND FONT

If it's any consolation, I am not a fan of the current SW API help format.  The user preference settings are a bit arcane, as well.

batHonesty may be the best policy, but insanity is a better defense.bat
http://www.EsoxRepublic.com-SolidWorks API VB programming help

RE: MACRO UNITS AND FONT

(OP)
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

RE: MACRO UNITS AND FONT

(OP)
do i need to make a new thread?

RE: MACRO UNITS AND FONT

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

RE: MACRO UNITS AND FONT

(OP)
hello, i got 2010 sp0.

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