Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create View (vb.net) using example from doc

Status
Not open for further replies.

iscariot

Mechanical
Oct 15, 2009
154
DE

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
 
Replies continue below

Recommended for you

did you reference the (usual suspects) CATIA libraries in your VB project references?


2018-03-14_18-57-55_z4wjky.png


2018-03-14_18-58-42_t56ixw.png


I suggest you check in CATIA VBA wwhich libraries your need...

Eric N.
indocti discant et ament meminisse periti
 
Actually I'm not sure :) I usually use same solution and I don't remember if I done this a really long time ago, or if I didn't do it at all.
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.


 
Nope, I don't think the references are the issues.

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?
 
In the end I have added the necessary references, I had imported them and I have declared everything.
Now it works.
 
thanks, cool that you get it to work

Eric N.
indocti discant et ament meminisse periti
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top