Catia Macro : Link Drawing Text to View Name
Catia Macro : Link Drawing Text to View Name
(OP)
Hello Everyone
I want to link drawing text to the View name so that whenever I change view name text is automatically updated. Is it possible through VBA ?
I want to link drawing text to the View name so that whenever I change view name text is automatically updated. Is it possible through VBA ?





RE: Catia Macro : Link Drawing Text to View Name
If you change it in the tree it will automatically change on the drawing.
If you change it on the drawing, then it doesn't change it in the tree and looses its link.
If link is lost or text is missing, you can rmb on the view name select object> add view name.
If you want a new piece of text somewhere else on the drawing to match a view name in the tree.
Create your text as you normally would, then select outside of the "text editor" window and rmb attribute link.
Then select the view from the tree. A second window will open, select view name from here then hit ok or apply.
Anytime you change the view name, this text should also change.
Not sure how to develop a macro for this, or if it would even be any quicker to use a macro.
RE: Catia Macro : Link Drawing Text to View Name
RE: Catia Macro : Link Drawing Text to View Name
RE: Catia Macro : Link Drawing Text to View Name
After a little bit of Hit n Trial I found the solution. Here is my code
CODE --> Catvba
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 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 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 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 SubAny Suggestion for improvement of same are always welcome
Thanks