Simple way to place drawing view inside drawing.

Simple way to place drawing view inside drawing.

C_Haines_ENG
Collaborator Collaborator
503 Views
5 Replies
Message 1 of 6

Simple way to place drawing view inside drawing.

C_Haines_ENG
Collaborator
Collaborator

I cant get any of the previous peices of code to work for this application. I would like to place a part file into a drawing, preferably in the center of the page. 

 

I have the below code but it wont allow me to select a specific file because it wont convert the String to a file document.

 

' Create new drawing document using specified template.
Dim oDrawingDoc As DrawingDocument
oDrawingDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "D:\ENG\Custom2022\Templates\Inventor\Standard (mm).dwg", True)

' a reference to the active sheet.
Dim oSheet As Sheet
oSheet = oDrawingDoc.ActiveSheet

' Create a new NameValueMap object.
Dim oBaseViewOptions As NameValueMap
oBaseViewOptions = ThisApplication.TransientObjects.CreateNameValueMap

' the representations to use when creating the base view.
oBaseViewOptions.Add("DesignViewRepresentation", "Default")
oBaseViewOptions.Add("DesignViewAssociative", False)

Dim oModel As Document
oModel = "C:\temp\test1\759500.ipt"

' Create the placement point object.
Dim oHeight As Double
Dim oWidth As Double

oHeight = oSheet.Height
oWidth = oSheet.Width

Dim oPoint As Point2d
oPoint = ThisApplication.TransientGeometry.CreatePoint2d(oWidth / 2, oHeight / 2)

' Create a base view.
Dim oBaseView As DrawingView
oBaseView = oSheet.DrawingViews.AddBaseView(oModel, oPoint, 1 / 36, kFrontViewOrientation, kHiddenLineRemovedDrawingViewStyle, , , oBaseViewOptions)

 

Any help would be great. 

0 Likes
Accepted solutions (2)
504 Views
5 Replies
Replies (5)
Message 2 of 6

WCrihfield
Mentor
Mentor
Accepted solution

Hi @C_Haines_ENG.

Try replacing this:

Dim oModel As Document
oModel = "C:\temp\test1\759500.ipt"

...with this:

Dim oModelFile As String = "C:\temp\test1\759500.ipt"
Dim oModel As Document = ThisApplication.Documents.Open(oModelFile, False)

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 6

C_Haines_ENG
Collaborator
Collaborator

"Parameter is Incorrect"

on line 

oBaseView = oSheet.DrawingViews.AddBaseView(oModel, oPoint, 1 / 36, kFrontViewOrientation, kHiddenLineRemovedDrawingViewStyle, , , oBaseViewOptions)
0 Likes
Message 4 of 6

WCrihfield
Mentor
Mentor
Accepted solution

I am not sure what else may be going wrong.  It looks OK to me.  Are you sure that part contains a design view representation named "Default"?  The online help page for that AddBaseView method indicates that those two 'options' are only for assemblies, but that does not sound correct, because parts can have DVR's too.  If you try that line without adding the options at the end, does it then work OK, but just maybe doesn't set the DVR correctly?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 6

C_Haines_ENG
Collaborator
Collaborator

The problem was infact the base view options. Thanks.

0 Likes
Message 6 of 6

WCrihfield
Mentor
Mentor

Hi @C_Haines_ENG.  I'm glad I was able to help.  But just in case it may be helpful, since there was problems with the options, you can actually set those options after you have added the view.  The DrawingView object has a method called SetDesignViewRepresentation which allows you to specify the name of the one you want to use, and specify whether or not you want it to be associative.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes