CHANGING UNITS QUICKLY
CHANGING UNITS QUICKLY
(OP)
thread560-328286: Changing Units Quickly
Hi Ferdo,
Below is the CATScript, given by you to toggle between the units,
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#, 3#
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#, 3#
oUnitsSheetSettingAtt.SaveRepositoryForUnits()
oUnitsSheetSettingAtt.CommitForUnits()
oUnitsSheetSettingAtt.Commit()
MsgBox "The Current Unit is now: " & oUnitMM
End If
CATIA.StartCommand "Options"
End Sub
I am getting a error trying to run it, please see attachment.
Please help.
Thanks for your time.
Hi Ferdo,
Below is the CATScript, given by you to toggle between the units,
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#, 3#
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#, 3#
oUnitsSheetSettingAtt.SaveRepositoryForUnits()
oUnitsSheetSettingAtt.CommitForUnits()
oUnitsSheetSettingAtt.Commit()
MsgBox "The Current Unit is now: " & oUnitMM
End If
CATIA.StartCommand "Options"
End Sub
I am getting a error trying to run it, please see attachment.
Please help.
Thanks for your time.





RE: CHANGING UNITS QUICKLY
Code was created for CATScript not catvba...copy and paste the code in a new text file (you can open a new one with Notepad, save the file then change the extention from txt to CATScript).
You need to read a little bit more careful the threads, it was written "Only with an automation tool (catscript....)".
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: CHANGING UNITS QUICKLY
Remove all brackets. If function doesn't take any arguments, You don't have to type brackets (in next step I'll show You how to call Subroutine with brackets)
Warning:
1.change all dash symbols (#) to proper values, e.g. 3.00000
probably You're using built-in VBA editor, it replace all strings, that are not given in brackets
to run CATIA's built-in SubRoutine replace lines as follow (it's an example, type Yours values)
CODE -->
LukaszSz. Poland, Warsaw University of Technology, Faculty of Power and Aeronautical Engineering : MEchanical Engineering. BsC - 2013
RE: CHANGING UNITS QUICKLY
Thanks for your time.
I implemented the changes you mentioned, the programme is running but with no desired results.
In first attachment: after running script. (I gave OK)
In second attchment: Window which pop up after giving ok.
Units still remains same. :(
Please help.
Thanks in advance
RE: CHANGING UNITS QUICKLY
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: CHANGING UNITS QUICKLY
RE: CHANGING UNITS QUICKLY
Hi Ferdo,
I have done the settings shown by you in above snap.
Please see the attchment. The dimension was in "inch", after running the macro the dimension still remains "inch".
Hi Jackk,
I am trying to change the units in drawing.
Thanks
Pradeep
RE: CHANGING UNITS QUICKLY
To change dimension units, change the dimension Numeric Display from NUM.DINC (or whatever you're using) to NUM.DIMM. Here's the steps to convert all dimensions interactively:
a. use EDIT + SEARCH to search and select all dimensions
b. select NUM.DIMM from the Numeric Display list in the top menu
RE: CHANGING UNITS QUICKLY
It is not possible to give the dual dimension by the method you have mentioned above. Catia will not allow you do that.
I have a script provided by one of the members, which will do it without any hassle.
Please see attachment.
Thanks
Pradeep
RE: CHANGING UNITS QUICKLY
a. use EDIT + SEARCH to search and select all dimensions
b. right-click on one of the highlighted dimensions and choose PROPERTIES
c. go the the VALUE tab, and select the Show Dual Value option
d. set the Description for the Main value (NUM.DIMM for millimeter units)
e. set the Descrittion for the Dual value (NUM.DINC for inch units)
f. OK
In a previous post you said you did not get the desired results with a script, but now you say you do have a script that will do it without any hassle ???
RE: CHANGING UNITS QUICKLY
Jackk, you are right, is nowhere specified that we are dealing with dual dimensions.
Also , in the reference thread question was
The script is doing exactly what was the original question in the reference thread, I completely agree with your observations (and CATIA methods by the way), star for this.
metipradeep, next time, it would be great to see what you tried in order to give you a better answer.
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: CHANGING UNITS QUICKLY
metipradeep has nowhere mentioned that he is trying to change units for dual dimensions.
so, this is indeed refers to just what the script does.
Regards,
Maddy