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!

Catia Macro Change Units

Status
Not open for further replies.

NaWin55

Mechanical
Mar 21, 2020
97
IN
Catia Macro to Change Dimensions Automatically

i want to create a macro to change dimension from any unity to any unit (Like mm to m or mm to cm)

i can select dimension and change visProperties and one dimension but how do i change the unit of several dimensions

here is the macro

Option Explicit

Sub CATMain()

Dim draDoc As DrawingDocument
Set draDoc = CATIA.ActiveDocument

Dim draSheets As DrawingSheets
Set draSheets = draDoc.Sheets

Dim drawDheet As DrawingSheet
Set drawDheet = draSheets.Item("Sheet.1")

Dim views As DrawingViews
Set views = drawDheet.views


Dim draDimensions As DrawingDimensions
Set draDimensions = views.Item("Front view")

Dim oSel As Selection
Set oSel = CATIA.ActiveDocument.Selection

CATIA.ActiveDocument.Selection.Clear

oSel.Search ("Drafting.Dimension,all")
MsgBox oSel.Count

End Sub


 
Replies continue below

Recommended for you

Here is my vb.net code to do this. Has been pretty robust so far. I'm sure you could easily adapt it to change other units as well.

Sub unitToggle()
Dim knowledgeSheetSettingAtt1 As KnowledgewareTypeLib.KnowledgeSheetSettingAtt
Dim settingControllers1 As INFITF.SettingControllers
Dim unitsSheetSettingAtt1 As KnowledgewareTypeLib.UnitsSheetSettingAtt
Dim setUnitType As String
Dim unitType As String = ""
Dim double1 As Double
Dim double2 As Double

settingControllers1 = MainForm.CATIA.SettingControllers
unitsSheetSettingAtt1 = settingControllers1.Item("CATLieUnitsSheetSettingCtrl")

unitsSheetSettingAtt1.GetMagnitudeValues("LENGTH", unitType, double1, double2)

If unitType = "Inch" Then
setUnitType = "Millimeter"
Else
setUnitType = "Inch"
End If

unitsSheetSettingAtt1.SetMagnitudeValues("LENGTH", setUnitType, 4, 3)

knowledgeSheetSettingAtt1 = settingControllers1.Item("CATLieKnowledgeSheetSettingCtrl")

knowledgeSheetSettingAtt1.SaveRepository()
knowledgeSheetSettingAtt1.Commit()
unitsSheetSettingAtt1.SaveRepositoryForUnits()
unitsSheetSettingAtt1.CommitForUnits()
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top