Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Measure Macro 1

Status
Not open for further replies.

sirbartoo

Mechanical
Sep 8, 2005
53
I am constantly changing between in. and mm. in my measure tool. Does anyone know of a macro that will automaticly open the measure tool in inches, and a second macro that will open the measure tool in mm? Maybe macro is not the way to go...I'm not sure how to address this issue, any suggestions?
 
Replies continue below

Recommended for you

I have not seen a macro for this. Someone may have one somewhere. It would be a good Enhancement Request to show both units.
You can dimension to show both units, then delete the dim.

Chris
SolidWorks 07 4.0/PDMWorks 07
AutoCAD 06
ctopher's home (updated 04-21-07)
 
I COULD DIM AND THEN DELETE, BUT THAT'S NOT WHAT I AM LOOKING FOR. I AM LOOKING TO UPGRADE MY ABILITY TO MEASURE.
 
There is no API access to the measure tool in SW 2007. However, you can toggle your document units back and forth between inches and mm with the following macro:

Code:
Sub DocUnitToggle()

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

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

CurUnits = swDoc.GetUserPreferenceIntegerValue(swUnitsLinear)

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

End Sub

This has the exact same effect as going to Tools->Options, Document Properties tab, Units category and changing "Length Units" back and forth between inches and millimeters. As long as the Measure tool's options (the in/mm button on the measure tool) is set to "Use Document setting" rather than "Use custom setting" this will work. The only slightly hairy thing is that the change of units will not be reflected on any current measurement. The set of selections must be changed to force Measure to recalculate the measurement. For example, say you select two faces and then bring up the measure tool. The distance is shown as 25.4mm, but you want to know inches. If you run the unit toggle macro, the measure tool won't immediately show 1". You would have to change the selection set by deselecting and reselecting a face or something similar.
 
A better ER might be for a simpler toggle (less mouse clicks), within the Measure dialogue box, to switch units. I guess that might be awkward though because there are 11 units to choose from. Maybe having a primary (default) and secondary unit pre-selection option (same as dual dimensions) could be incorporated.

[cheers]
 
I like handleman's solution best. I don't think the measure dialog box is the right place to be quickly switching units.

I also like CBL's suggestion about having duals units in the measure dialog. I would support that ER.


Matt
CAD Engineer/ECN Analyst
Silicon Valley, CA
sw.fcsuper.com
Co-moderator of Solidworks Yahoo! Group
 
So how do we give Solidworks an Enhancement Request?
 
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?

Larry Jorgenson, P.Eng (Mechanical - U of S, 1994)
Prairie Agricultural Machinery Institute (PAMI)
Humboldt, SK Canada
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor