Hello All Users,
I found a macro to add text to a view from the Coe platform. However, I can only add View name and Scale properties to text in the macro. I want to add different properties as a new line is that possible?
For example, I need to add values in part properties. Information such as Part Number, Revision, Material or user Properties. The picture contains information I want to add.
Can I add a linked attribute using MyDrawingView.Texts.Add?
Dim MyText As DrawingText
Set MyText = MyDrawingView.Texts.Add(vbCrLf + "Scale", TextLocation(0), TextLocation(1))
Here is the total code:
Sub CatMain()
Dim MyDoc As Document
Set MyDoc = CATIA.ActiveDocument
If TypeName(MyDoc) <> "DrawingDocument" Then
MsgBox "This macro works in Drafting Workbench", vbCritical, "Error"
End If
Dim MyDrawingDoc 'As DrawingDocument
Set MyDrawingDoc = MyDoc
Dim MySelection 'As Selection
Set MySelection = MyDrawingDoc.Selection
Dim Status As String
Dim vFilter(0)
vFilter(0) = "DrawingView"
MySelection.Clear
Status = MySelection.SelectElement2(vFilter, "Select Drawing View", True)
If Status = "Cancel" Then
End If
Dim MyDrawingView As DrawingView
Set MyDrawingView = MySelection.Item(1).Value
MyDrawingView.Activate
Dim MyDrawingSheet As DrawingSheet
Set MyDrawingSheet = MyDrawingView.Parent
Dim TextLocation(1)
Status = MyDrawingDoc.Indicate2D("Indicate Text Location", TextLocation)
If Status = "Cancel" Then
End If
Dim MyText As DrawingText
Set MyText = MyDrawingView.Texts.Add(vbCrLf + "Scale", TextLocation(0), TextLocation(1))
Dim ParameterName As String
ParameterName = "Drawing" + MyDrawingSheet.Name + "" + MyDrawingView.Name + "\Name"
Call MyDrawingView.InsertViewScale(1 + Len(MyText.Text), MyText)
Call MyText.InsertVariable(1, 0, MyDrawingDoc.Parameters.GetItem(ParameterName))
End Sub
Thank you.
AKIN KUZEYI