Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TugboatEng on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

trigger catia

Joined
Apr 22, 2025
Messages
2
Hello,

I’m trying to achieve the following in CATIA:
  • When the user clicks Save on the active document in CATIA, a message box should appear.
  • At the same time, a macro should run automatically and display the results.
Alternatively, if the user clicks a custom button in the UI for the active document, and then later clicks Save, it should still trigger the message box.
Here's the code I’ve tried so far:

Public WithEvents partDoc As PartDocument
Public WithEvents prodDoc As ProductDocument
Public WithEvents drawDoc As DrawingDocument

Public Sub Init(doc As Document)
' Check the document type and set the appropriate object for events
Dim docTypeName As String
docTypeName = LCase(TypeName(doc))

Select Case docTypeName
Case "partdocument"
Set partDoc = doc
Case "productdocument"
Set prodDoc = doc
Case "drawingdocument"
Set drawDoc = doc
Case Else
MsgBox "Unsupported document type: " & docTypeName, vbCritical
Exit Sub
End Select

MsgBox "Save event agent enabled for: " & docTypeName
End Sub

Private Sub partDoc_OnBeforeSave()
MsgBox "Saving Part... Agent triggered!"
End Sub

Private Sub prodDoc_OnBeforeSave()
MsgBox "Saving Product... Agent triggered!"
End Sub

Private Sub drawDoc_OnBeforeSave()
MsgBox "Saving Drawing... Agent triggered!"
End Sub


regards
Gokul
 
Not possible with VB. There're no event APIs in CATIA automation.

Document can be saved by numerous ways, it's not possible to monitor it reliably.
 
Just use the built in Save Management. I don't see a point of having a window saying "Hey look, I'm saving your document, how awesome am I!"
 
Exactly, what is the point of introducing save trigger?
 

Part and Inventory Search

Sponsor

Back
Top