Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

How can I relink broken drawing views to a CATProduct using script? 1

Status
Not open for further replies.

Kattmandu

Automotive
Oct 31, 2022
7
0
0
US
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).

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

 
 https://files.engineering.com/getfile.aspx?folder=a1da4931-8533-4f3b-822b-c7826ff1a254&file=Capture.JPG
Replies continue below

Recommended for you

Status
Not open for further replies.
Back
Top