Place part views on active sheet

Place part views on active sheet

blindholm16
Contributor Contributor
451 Views
1 Reply
Message 1 of 2

Place part views on active sheet

blindholm16
Contributor
Contributor

Attempting to use this iLogic below to select a part and then place two views on the active sheet, not seeing why the views are not getting generated. Any help appreciated.

Imports Inventor.ViewOrientationTypeEnum
Imports Inventor.DrawingViewStyleEnum

Dim oDrawingDoc As DrawingDocument
Dim oPartDoc As PartDocument
Dim oSheet As Sheet
Dim oIsoView As DrawingView
Dim oFlatView As DrawingView

ViewScaleFlat = 1 / 4
ViewScaleIso = 1/14

'Present a File Selection dialog
Dim oFileDlg As Inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDlg)
oFileDlg.InitialDirectory = oOrigRefName
oFileDlg.CancelError = True
On Error Resume Next
oFileDlg.ShowOpen()
If Err.Number <> 0 Then
Return
ElseIf oFileDlg.FileName <> "" Then
oPartDoc = oFileDlg.FileName
End If

' Current open drawing sheet
oDrawingDoc = ThisApplication.ActiveDocument
oSheet = oDrawingDoc.ActiveSheet

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

'False = flat pattern view
oBaseViewOptions.Add("SheetMetalFoldedModel", False) 

'Bottom left corner points for views
oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(7, 7.125) ' iso view
oPoint2 = ThisApplication.TransientGeometry.CreatePoint2d(20, 18)' flat pattern

'Place the Views
oIsoView = oSheet.DrawingViews.AddBaseView(oPartDoc, oPoint1, ViewScaleIso, kIsoTopRightViewOrientation, kHiddenLineRemovedDrawingViewStyle)
oFlatView = oSheet.DrawingViews.AddBaseView(oPartDoc, oPoint2, ViewScaleFlat, kDefaultViewOrientation, kHiddenLineDrawingViewStyle, , , oBaseViewOptions)

BL
0 Likes
Accepted solutions (1)
452 Views
1 Reply
Reply (1)
Message 2 of 2

JamieVJohnson2
Collaborator
Collaborator
Accepted solution

oPartDoc = oFileDlg.FileName

 

part doc = file path ---> not going to work, this you don't know because of On Error Resume Next.

 

Replace your OnError thinking with the better Try/Catch/Finally method of error capturing.

Use these methods to get a document from the Application.Documents

Documents.Open(filepath)

or

Documents.OpenWithOptions(filepath,options,openvisibleorhidden)

or

for each doc in Documents

if doc.fullfilename = filepath then

partdoc=doc

end if

next

Jamie Johnson : Owner / Sisu Lissom, LLC https://sisulissom.com/
0 Likes