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!

Icon / Toolbar to Switch Units

Status
Not open for further replies.

drewboy23

Mechanical
Jan 30, 2004
55
I've tried but cannot figure out. Is there a way to create a macro or something to make an icon that I can toggle back and forth between inches and millimeters?

Appreciate the help!
 
Replies continue below

Recommended for you

Not sure if you really need a macro for this.

Just set the properties to the units you use most often, and then add a " (or mm) after the number when you need to use a value in the other unit.
 
Hi

This is a CATScript which I posted in a Spanish forum:

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"

call CATIA.SystemService.ExecuteBackGroundProcessus("WScript.exe c:\SendEnter.vbs")

End Sub


Paste what is bellow in a file named SendEnter.vbs (vbs is the extension of the file)

Set WshShell = WScript.CreateObject("WScript.Shell")
WScript.sleep 200
WshShell.SendKeys "{ENTER}"

Regards
Fernando
 
Thanks Ferdo! Just what i needed. It's more of less for for when measuring and checking items rather then inputing sizes when designing. If I could set dual unit's when measuring - that would be useful also.
 
Hi,

I ran the script and like the way it works, however if your are not on the Tools/Options/Paramaters and Measures/Units page, it does not allow you to click ok and the switch doesnt take affect until I go to this page. Is this a glitch in Catia. Is there a way around this so I dont have to this or say ok everytime I switch units....just wondering
 
That's why you need the second vbs file, directly on c:\ , its sending Enter from keyboard.

Regards
Fernando
 
I did use the second vbs file, but if my tools option page is not on the units page, it says ok for me but still measures in the original unit, then when i check the units in tools options, it has switched. if i'm on the units page and run the macro, it waits for me to say ok then it works
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor