LucasC
Automotive
- Feb 18, 2019
- 157
Hi all,
I'm new to visbasic and Ive hit a roadblock. I simply want to open the linked 3D model that the CATDrawing is based on. I've looked through the onboard help but it isn't clear (to me) on what to do.
Here's the code I have so far. I'm stuck with "ViewLink" (I underlined the code line) returning a null value. Any suggestions would be appreciated.
-Chris
Sub catmain()
'Get a hold of the active document
Dim Doc1 As Document
Set Doc1 = CATIA.ActiveDocument
'check if a CATDrawing is open
If InStr(Doc1.Name, ".CATDrawing") = 0 Then
MsgBox "The Active Document must be a CATDrawing."
Exit Sub
End If
'get a hold of the drawing document
Dim drwdoc As drawingDocument
Set drwdoc = Doc1
'get a hold of the sheet
Dim drwsheet As drawingSheet
Set drwsheet = drwdoc.Sheets.Item(1)
'get a hold of view 1
Dim View1 As DrawingView
Set View1 = drwsheet.Views.Item(1)
'get a hold of the view link
Dim viewlink As DrawingViewGenerativeBehavior
Set viewlink = View1.GenerativeBehavior.Document.Parent
'asign view link to parameter
Dim link--1 As DrawingView--GenerativeLinks 'added dashes to display correctly in forums
Dim mylink--1 A-s Drawing--ViewGenerativeLinks 'added dashes to display correctly in forums
Set link--1 = viewlink.Generative--Links 'added dashes to display correctly in forums
viewlink.CopyLinksTo (mylink)
'Open the pointed 3D model
CATIA.Documents.Open (mylink)
'Update The drawing
End Sub
I'm new to visbasic and Ive hit a roadblock. I simply want to open the linked 3D model that the CATDrawing is based on. I've looked through the onboard help but it isn't clear (to me) on what to do.
Here's the code I have so far. I'm stuck with "ViewLink" (I underlined the code line) returning a null value. Any suggestions would be appreciated.
-Chris
Sub catmain()
'Get a hold of the active document
Dim Doc1 As Document
Set Doc1 = CATIA.ActiveDocument
'check if a CATDrawing is open
If InStr(Doc1.Name, ".CATDrawing") = 0 Then
MsgBox "The Active Document must be a CATDrawing."
Exit Sub
End If
'get a hold of the drawing document
Dim drwdoc As drawingDocument
Set drwdoc = Doc1
'get a hold of the sheet
Dim drwsheet As drawingSheet
Set drwsheet = drwdoc.Sheets.Item(1)
'get a hold of view 1
Dim View1 As DrawingView
Set View1 = drwsheet.Views.Item(1)
'get a hold of the view link
Dim viewlink As DrawingViewGenerativeBehavior
Set viewlink = View1.GenerativeBehavior.Document.Parent
'asign view link to parameter
Dim link--1 As DrawingView--GenerativeLinks 'added dashes to display correctly in forums
Dim mylink--1 A-s Drawing--ViewGenerativeLinks 'added dashes to display correctly in forums
Set link--1 = viewlink.Generative--Links 'added dashes to display correctly in forums
viewlink.CopyLinksTo (mylink)
'Open the pointed 3D model
CATIA.Documents.Open (mylink)
'Update The drawing
End Sub