×
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

Need macro to change default /dual units & precision

Need macro to change default /dual units & precision

Need macro to change default /dual units & precision

(OP)
What i would like to have is a macro that makes my document use and measure dual dimensions, with 6 decimals on both the primary and alternate units.  What i have so far makes the units work and fixes the precision on the measured units, but it does nothing for the precision on the modeled units.  ie, the dimensions that you use to build the model dont go to the correct precision, but you get the correct precision in the measure tool.

Here is what im starting with, all of which works fine:

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, swDualDimensionsOnTop
Part.SetUserPreferenceIntegerValue swUnitsLinear, swMM
Part.SetUserPreferenceIntegerValue swUnitsLinearDecimalPlaces, 6
Part.SetUserPreferenceIntegerValue swUnitsAngularDecimalPlaces, 5
Part.SetUserPreferenceIntegerValue swUnitsDualLinear, swINCHES
Part.SetUserPreferenceIntegerValue swUnitsDualLinearDecimalPlaces, 6
End Sub

However, what i ALSO need is a way to use  swDetailingLinearDimPrecision and swDetailingAltDimPrecision properly.  I have tried the following lines to no avail:
boolstatus = Part.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swDetailingAltDimPrecision, swUserPreferenceOption_e.swDetailingDimension, 6)
boolstatus = Part.SetUserPreferenceIntegerValue(swUserPreferenceIntegerValue_e.swDetailingAltDimPrecision, 6)
Part.SetUserPreferenceIntegerValue swDetailingAltDimPrecision, 6

I know that i can change the template to get my precision changed for new parts, but i want it to alter old parts too.
My machine is a 64 bit, and I am running SW 2009, SP5.0

I dont really know a lot about VBA -  most of my knowledge comes from forum surfing, so most of my problem is likely a basic lack of syntax comprehension, but i have flailed away at this long enough that its time to start asking for help.

thanks!
  

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