Catia Macro: Create Text Below Drawing Dimensions
Catia Macro: Create Text Below Drawing Dimensions
(OP)
Hello All,
I have to create text indicating number below each and every dimension for every view. See the attached image for more clarity. Right now I am doing it manually. I want to automate this process. I have created a macro for it. But the problem is that I text is not coming at a desired place. Its location is far away from dimensions. Any help regarding this will be highly appreciated. Here is my code.
I have to create text indicating number below each and every dimension for every view. See the attached image for more clarity. Right now I am doing it manually. I want to automate this process. I have created a macro for it. But the problem is that I text is not coming at a desired place. Its location is far away from dimensions. Any help regarding this will be highly appreciated. Here is my code.
CODE --> VBA
Sub CATMain()
Dim MyDoc As DrawingDocument
Dim MySelection As Selection
Dim MySheet As DrawingSheet
Dim MyDrawingView As DrawingView
Dim MyDimensions As DrawingDimensions
Dim MyDimension As DrawingDimension
Dim MyText As DrawingText
Dim oValues(5)
Set MyDoc = CATIA.ActiveDocument
Set MySheet = MyDoc.DrawingRoot.ActiveSheet
Set MySelection = MyDoc.Selection
If MySelection.Count = 0 Then
MsgBox "Nothing Selected"
End
Else
If MySelection.Item(1).Type = "DrawingView" Then
Set MyDrawingView = MySelection.Item(1).Value
Set MyDimensions = MyDrawingView.Dimensions
Set MyDimension = MyDimensions.Item(1)
Dim MyDimV
Set MyDimV = MyDimension
Call MyDimension.GetBoundaryBox(oValues)
'MsgBox oValues(1)
Set MyText = MyDrawingView.Texts.Add("Temp", oValues(0), oValues(1))
Else
MsgBox "Wrong Selection"
End If
End If
End Sub 




RE: Catia Macro: Create Text Below Drawing Dimensions
Call MyDimension.GetBoundaryBox(oValues)
indocti discant et ament meminisse periti
RE: Catia Macro: Create Text Below Drawing Dimensions
CODE --> VBA
Sub CATMain() Dim MyDoc As DrawingDocument Dim MySelection As Selection Dim MySheet As DrawingSheet Dim MyDrawingView As DrawingView Dim MyDimensions As DrawingDimensions Dim MyDimension As DrawingDimension Dim MyText As DrawingText Dim oValues(5) Set MyDoc = CATIA.ActiveDocument Set MySheet = MyDoc.DrawingRoot.ActiveSheet Set MySelection = MyDoc.Selection If MySelection.Count = 0 Then MsgBox "Nothing Selected" End Else If MySelection.Item(1).Type = "DrawingView" Then Set MyDrawingView = MySelection.Item(1).Value Set MyDimensions = MyDrawingView.Dimensions Set MyDimension = MyDimensions.Item(1) Dim MyDimV Set MyDimV = MyDimension Call MyDimV.GetBoundaryBox(oValues) 'MsgBox oValues(1) Set MyText = MyDrawingView.Texts.Add("Temp", oValues(0), oValues(1)) Else MsgBox "Wrong Selection" End If End If End SubRE: Catia Macro: Create Text Below Drawing Dimensions
The text comes in right position for me on a simple length dim.
indocti discant et ament meminisse periti
RE: Catia Macro: Create Text Below Drawing Dimensions
CODE --> CATScript
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Catia Macro: Create Text Below Drawing Dimensions
RE: Catia Macro: Create Text Below Drawing Dimensions
CODE --> CATScript
Sub CATMain() Dim MyDoc As DrawingDocument Dim MySelection As Selection Dim MySheet As DrawingSheet Dim MyDrawingView As DrawingView Dim MyDimensions As DrawingDimensions Dim MyDimension As DrawingDimension Dim MyText As DrawingText Dim oValues(5) Set MyDoc = CATIA.ActiveDocument Set MySheet = MyDoc.DrawingRoot.ActiveSheet Set MySelection = MyDoc.Selection If MySelection.Count = 0 Then MsgBox "Nothing Selected" Exit Sub Else If MySelection.Item(1).Type = "DrawingView" Then Set MyDrawingView = MySelection.Item(1).Value Set MyDimensions = MyDrawingView.Dimensions For i = 1 To MyDimensions.Count Set MyDimension = MyDimensions.Item(i) Dim MyDimV Set MyDimV = MyDimension Call MyDimV.GetBoundaryBox(oValues) Set MyText = MyDrawingView.Texts.Add("No. 000" & i, oValues(0), oValues(1)) Next Else MsgBox "Wrong Selection" End If End If End SubRegards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Catia Macro: Create Text Below Drawing Dimensions
3D model has many axis systems. is it creating some problem in my case ??
Text is created at position that is far away from the respective dimension.
RE: Catia Macro: Create Text Below Drawing Dimensions
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Catia Macro: Create Text Below Drawing Dimensions
RE: Catia Macro: Create Text Below Drawing Dimensions
Workaround...
CODE --> CATScript
Sub CATMain() msgbox "Select View to Activate" Dim InputObject(0) InputObject(0) = "DrawingView" Dim DrwSelect As Selection Set DrwSelect = CATIA.ActiveDocument.Selection Status = DrwSelect.SelectElement2(InputObject, "Select View", False) CATIA.StartCommand"Activate View" DrwSelect.Clear Dim ZAEHLER As integer Dim Status Dim Position(1) Dim drawingTexts1 As DrawingTexts Dim drawingText1 As DrawingText Dim Textbezeichnung As String set drawingtexts1 = catia.activedocument.sheets.activesheet.views.activeview.texts counter = inputbox ("Starting Numberr : default is written No. 000", "Input", 1) msgBox "You can EXIT at any moment using ESC taste" do Status = CATIA.ActiveDocument.Indicate2D("Select point (EXIT with ESC)", Position) If (Status = "Cancel") Then MsgBox "Aborted" Exit Sub End If On Error Resume Next TextCounter = "No. " & "000" & counter Set drawingText1 = drawingTexts1.Add(TextCounter, Position(0), Position(1)) drawingText1.Text = TextCounter counter = counter+1 loop End SubRegards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Catia Macro: Create Text Below Drawing Dimensions
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Catia Macro: Create Text Below Drawing Dimensions
RE: Catia Macro: Create Text Below Drawing Dimensions
Now I have another problem. Can we specify text Position and orientation link with VBA during its creation ?
RE: Catia Macro: Create Text Below Drawing Dimensions
I used MyText.AssociatedElement = MyDimension but it only creates positional link. However my requirement is for orientation link otherwise I have to manually orient each and every dim in case of non-horizontal orientation.
Is there any direct way to get orientation of dim text and apply same to the text?