I tried and failed to create a view using the example from documentation.
If I used it in CATScript it is working, but if I move it in vb.net it fails at below line with error "Member not found":
Code:
oFrontViewGB.Document = oPartToDraw
What am I missing?
Help is highly appreciate
Code:
' -----------------------------------------------------------
' Optional: allows to find the sample wherever it's installed
dim sDocPath As String
'sDocPath = CATIA.SystemService.Environ("CATDocView")
sDocPath = "\\..........\documentation\CATIAV5\v5r21\English"
If (Not CATIA.FileSystem.FolderExists(sDocPath)) Then
Debug.Print("No Doc Path Defined")
Exit Sub
End If
' -----------------------------------------------------------
' Open the Part document
Dim oPartToDraw As Object 'PartDocument
oPartToDraw = CATIA.Documents.Open(sDocPath & "\online\CAAScdDriUseCases\samples\Cube.CATPart")
' Create a drawing document: it becomes the active document.
Dim oDrawing As Object 'DrawingDocument
oDrawing = CATIA.Documents.Add("Drawing")
' Retrieve the active sheet
Dim oSheet As Object 'DrawingSheet
oSheet = oDrawing.Sheets.ActiveSheet
' Create a view called "Front View" in this sheet
Dim oFrontView As Object 'DrawingView
oFrontView = oSheet.Views.Add("Front View")
' Retrieve it generative behavior
Dim oFrontViewGB As Object 'DrawingViewGenerativeBehavior
oFrontViewGB = oFrontView.GenerativeBehavior
' Debug.Print(TypeName(oPartToDraw))
' Debug.Print(oPartToDraw.Name)
' Declare the part to draw in this front view
oFrontViewGB.Document = oPartToDraw
' Define this view as a front view, with the XY plane (in oPartToDraw) as projection plane
oFrontViewGB.DefineFrontView (1, 0, 0, 0, 1, 0)
' Position the View in the Sheet
oFrontView.x = 300
oFrontView.y = 150
' Update the view
oFrontViewGB.Update