05-22-2019
10:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
05-22-2019
10:41 AM
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
Solved! Go to Solution.
05-22-2019
11:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
05-22-2019
11:20 AM
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
jvj