Create View (vb.net) using example from doc
Create View (vb.net) using example from doc
(OP)
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 --> vb.net
oFrontViewGB.Document = oPartToDraw
What am I missing?
Help is highly appreciate :)
CODE --> vb.net
' -----------------------------------------------------------
' 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 




RE: Create View (vb.net) using example from doc
I suggest you check in CATIA VBA wwhich libraries your need...
indocti discant et ament meminisse periti
RE: Create View (vb.net) using example from doc
I will check this and provide feedback.
I suppose I should add and use always all necessary references but I got used without them :(
Thank you for the answer.
RE: Create View (vb.net) using example from doc
I have added below references, but still does not work:
CV5 ApplicationFrame Obj Lib
CV5 Interfaces Obj Lib
CV5 MecModInterfaces Obj Lib
CV5 Product structureInterfaces Obj Lib
CV5 DraftingInterfaces Obj Lib.
I am starting to think that it is not possible to create a view in vb.net :(
Any ideas?
RE: Create View (vb.net) using example from doc
Now it works.
RE: Create View (vb.net) using example from doc
indocti discant et ament meminisse periti