×
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

Icon / Toolbar to Switch Units

Icon / Toolbar to Switch Units

Icon / Toolbar to Switch Units

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

RE: Icon / Toolbar to Switch Units

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.

RE: Icon / Toolbar to Switch Units

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

RE: Icon / Toolbar to Switch Units

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

RE: Icon / Toolbar to Switch Units

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

RE: Icon / Toolbar to Switch Units

That's why you need the second vbs file, directly on c:\ , its sending Enter from keyboard.

Regards
Fernando

RE: Icon / Toolbar to Switch Units

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

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