Continue to Site

Welcome to 3DCADForums

Join our CAD community forums where over 25,000 users interact to solve day to day problems and share ideas. We encourage you to visit, invite you to participate and look forward to your input and opinions. Acrobat 3D, AutoCAD, Catia, Inventor, IronCAD, Creo, Pro/ENGINEER, Solid Edge, SolidWorks, and others.

Setting the Tools->Options

dbwalters

New member
Hello, I have written a CATSCRIPT that will change the unit parameter LENGTH from INCH to MILLIMETER (or vice-versa). This change happens when a button is selected on the user's toolbar. The button will save the user some time since he/she doesn't have to access TOOLS->OPTIONS each time to change this parameter. Even though the change actually takes effect, CATIA doesn't think that anything has happened. When I go to verify the change in TOOLS->OPTIONS->PARAMETERS AND MEASURES->UNITS I can see it has taken place, but, it is not until I hit the 'OK' button on that panel that CATIA recognizes it.
Does anyone have an idea on what I can do in my code to provide the same authorization as the 'OK' button? Is there an "update" that I am missing?

Below is a copy of the VBSCRIPT I am using:

Code:
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()
          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()
          MsgBox "The Current Unit is now: " & oUnitMM
     End If

End Sub

Any information or assistance that you can provide would be appreciated.

Thanks in advance.
 
thanks for the ideas

Thanks for the additional ideas. The one link is to a thread of mine that I posted on the COE website. I am seeing if anyone has any answers over there...So far, no luck either. I keep trucking on trying to find a resolution.
 
I believe that I found a solution to my problem. All that was needed was the following two lines of code:

CATIA.StartCommand("Options...")
CATIA.ActiveWindow.Close

Now everything works. Thanks.
 

Articles From 3DCAD World

Sponsor

Back
Top