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.

metipradeep

Aerospace
Apr 22, 2013
14
thread560-328286

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.
 
Replies continue below

Recommended for you

Hi,

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

 
Error:
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:
Call oUnitsSheetSettingAtt.SetMagnitudeValues(oMagnitude, oUnitInch, 6.000, 3.000)

LukaszSz. Poland, Warsaw University of Technology, Faculty of Power and Aeronautical Engineering : MEchanical Engineering. BsC - 2013
 
Hi LukaszSz,

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
 
 http://files.engineering.com/getfile.aspx?folder=7b4b984a-8a8d-4455-b70a-bc7d0bda0bb6&file=dual_2.jpg
You need to check

Options.jpg


Regards
Fernando

 
Pradeep, which units are you trying to change? the 3D working units (CATPart), or the drawing dimension units? How do you know the units are still the same?
 


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
 
I think your script is changing the drawing units that effect measures and geometry creation/modification, but does NOT drawing dimensions.

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
 
Hi Jackk,

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
 
 http://files.engineering.com/getfile.aspx?folder=d05897f0-a66c-485b-9558-10840ab5b5f7&file=Dual.CATScript
I didn't realize we were dealing with Dual Dimensions in this thread. It is indeed possible and easy to manualy (interactively) change the units of dual dimensions, however it requires changing the dimension properties after selecting all dimensions.

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 ???
 
Hi,

Jackk, you are right, is nowhere specified that we are dealing with dual dimensions.

Also , in the reference thread question was
JMorton said:
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?

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

 
Yes, I do agree with you jack.
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor