Gokul Shanmugasundaram
Automotive
- Apr 22, 2025
- 1
Hello,
I’m trying to achieve the following in CATIA:
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
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.
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