×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Catia Macro : Link Drawing Text to View Name

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 ?

RE: Catia Macro : Link Drawing Text to View Name

By default the name of the view shown on the drawing will match what is in your tree.
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

When you change the view name using the "view properties" function, it should always update the text attribute. If you wish to link the view name to some other feature, simply do what rickyt suggests and apply an attribute link to the text block.

RE: Catia Macro : Link Drawing Text to View Name

(OP)
Actually I am developing a macro. I am more interested in how to do it through VBA rather than manually

RE: Catia Macro : Link Drawing Text to View Name

(OP)
Hello Friends
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 Sub 

Any Suggestion for improvement of same are always welcome

Thanks

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources