Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Changing Units Quickly 1

Status
Not open for further replies.

JMorton

Aerospace
Aug 6, 2012
16
US
Hello is there a way in CATIA where you can create a button that allows you to change quickly between metric and US units without having to go through the tools menu and options to change it every time?

Thank you.
 
Replies continue below

Recommended for you

Question was about workbench, but anyway doesn't matter, ussualy peoples are asking about this to change in one click units from mm to in (or viceversa) for dimensions in drawings... I guess you want something else, check if is working properly for you (for me is OK in r18).

' ======================================================
' Purpose: Macro will toggle the current measure unit in an active CATIA session
' Usage: 1 - A CATIA session must exist
' 2 - Run macro
' Author: ferdo (Disclaimer: You use this code at your own risk)
' ======================================================
Language="VBSCRIPT"
Sub CATMain()

Dim oSettingControllers As SettingControllers
Set oSettingControllers = CATIA.SettingControllers
Dim oUnitsSheetSettingAtt As SettingController
Set oUnitsSheetSettingAtt = oSettingControllers.Item("CATLieUnitsSheetSettingCtrl")
Dim oMagnitude as String
oMagnitude = "LENGTH"
Dim oUnit as String
oUnit = ""
Dim oGetDecimal as Double
Dim oGetExpo as Double
oUnitsSheetSettingAtt.GetMagnitudeValues oMagnitude, oUnit, oGetDecimal, oGetExpo

If (oUnit = "Inch") Then
Dim oUnitInch as String
oUnitInch = "Millimeter"
oUnitsSheetSettingAtt.SetMagnitudeValues oMagnitude, oUnitInch, 6.000000, 3.000000
oUnitsSheetSettingAtt.SaveRepositoryForUnits()
oUnitsSheetSettingAtt.CommitForUnits()
oUnitsSheetSettingAtt.Commit()
MsgBox "The Current Unit is now: " & oUnitInch
End If

If (oUnit = "Millimeter") Then
Dim oUnitMM as String
oUnitMM = "Inch"
oUnitsSheetSettingAtt.SetMagnitudeValues oMagnitude, oUnitMM, 6.000000, 3.000000
oUnitsSheetSettingAtt.SaveRepositoryForUnits()
oUnitsSheetSettingAtt.CommitForUnits()
oUnitsSheetSettingAtt.Commit()
MsgBox "The Current Unit is now: " & oUnitMM
End If

CATIA.StartCommand "Options"

End Sub

Regards
Fernando

 
JMorton,

Another option is to type in the units along with the value. This is quick and handy, if you only have a few numbers to convert on-the-fly.

For example; if the current units are set to MM, you could type in 2in, and CATIA will convert from inches to millimeters. I'm not sure of all the unit abbreviations, but you could also use "ft" pr "cm". There are many others.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top