Kattmandu
Automotive
- Oct 31, 2022
- 7
thread560-356588
I found the VBA script below in the thread linked above which drewmumaw created/posted. How can I rewrite it to work with a CATProduct? It works when I use a CATPart but if I change it to a CATProduct I receive a scripting error (see attachment at bottom).
I found the VBA script below in the thread linked above which drewmumaw created/posted. How can I rewrite it to work with a CATProduct? It works when I use a CATPart but if I change it to a CATProduct I receive a scripting error (see attachment at bottom).
Code:
Sub CATMain()
Dim drawingDocument1 As DrawingDocument
Set drawingDocument1 = CATIA.ActiveDocument
Dim drawingSheets1 As DrawingSheets
Set drawingSheets1 = drawingDocument1.Sheets
Dim drawingSheet1 As DrawingSheet
Set drawingSheet1 = drawingSheets1.ActiveSheet
Dim drawingViews1 As DrawingViews
Set drawingViews1 = drawingSheet1.Views
Dim drawingView1 As DrawingView
Set drawingView1 = drawingViews1.ActiveView
Dim viewLinks1 As DrawingViewGenerativeLinks
Set viewLinks1 = drawingView1.GenerativeLinks
viewLinks1.RemoveAllLinks
Dim partDocument1 As Document
Set partDocument1 = CATIA.Documents.Item("[b][COLOR=#EF2929]{filename}.CATPart[/color][/b]")
Dim viewBehavior As DrawingViewGenerativeBehavior
Set viewBehavior = drawingView1.GenerativeBehavior
viewBehavior.Document = partDocument1
viewBehavior.Update
End Sub