Thank you for your code. However, I was not able to make it work in Inventor 2012 Ilogic. I cleaned it up and removed the "SET" statements that are no longer used but I keep getting an error:
"Error in rule: FLAT PATTERN VIEW CREATE IN IDW, in document: FLAT PATTERN VIEW CREATE IN IDW.iLogicVb
Unable to cast COM object of type 'System.__ComObject' to interface type 'Inventor.DrawingDocument'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{29F0D467-C114-11D2-B77F-0060B0F159EF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
The codes I have currently that work and create the formed views of the sheet metal part is as follows:
'------------------------start of iLogic code ---------------------
Imports Inventor.ViewOrientationTypeEnum
Imports Inventor.DrawingViewStyleEnum
Dim oDrawingDoc as DrawingDocument
Dim oPartDoc as Document
Dim oSheet As sheet
Dim oTG As TransientGeometry
Dim oView1 as DrawingView
Dim oView2 as DrawingView
Dim oView3 as DrawingView
Dim oView4 as DrawingView
'GET SHEET METAL FLAT PATTERN EXTENTS LENGTH TO CALCULATE VIEW SCALES
'MessageBox.Show(iProperties.Value("Custom","FlatExtentsLength"), "Title")
'MessageBox.Show(iProperties.Value("Custom","FlatExtentsWidth"), "Title")
FLATPATTERNLENGTH = iProperties.Value("Custom","FlatExtentsLength")
FLATPATTERNWIDTH = iProperties.Value("Custom","FlatExtentsWidth")
'Calculate View Scale
If FLATPATTERNLENGTH >= FLATPATTERNWIDTH Then
ViewScale = 5/FLATPATTERNLENGTH
Else
ViewScale = 5/FLATPATTERNWIDTH
End If
'Ask to create drawing?
dwgQuery=MsgBox("Would you like to Create a drawing for this MODEL?", vbYesNo,"Drawing Selection")
If dwgQuery = vbYes Then
oPartDoc = ThisDoc.Document
'Define IDW Template File Location
oDrawingDoc = ThisApplication.documents.Add(kDrawingDocumentObject, "pathandfilename.IDW", True)
oSheet = oDrawingDoc.Sheets.Item(1)
'Define 2d view bottom left corner points for four views
oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(25#, 15#)
oPoint2 = ThisApplication.TransientGeometry.CreatePoint2d(33#, 15#)
oPoint3 = ThisApplication.TransientGeometry.CreatePoint2d(25#, 20#)
oPoint4 = ThisApplication.TransientGeometry.CreatePoint2d(4#, 10#)
oView1 = oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint1, ViewScale,kFrontViewOrientation, _
kHiddenLineRemovedDrawingViewStyle)', KTANGENTEDGESON)
oView2 = oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint2, _
ViewScale,kRightViewOrientation,kHiddenLineRemovedDrawingViewStyle)
oView3 = oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint3, _
ViewScale,kTopViewOrientation,kHiddenLineRemovedDrawingViewStyle)
'-----------------------Flat Pattern View Section-------------------------------------------------------------------------
'This is the code line which I wish to use to add the sheet metal flat patter default view:
oView4 = oSheet.DrawingViews.AddBaseView(oPartDoc, oPoint4, _
ViewScale,kIsoTopRightViewOrientation,kHiddenLineRemovedDrawingViewStyle, kSheetMetalFlatPattern, _
Camera1)'"sheetmetalflatpattern")'oBaseViewOptions)
End If
'--------------------end of iLogic code-------------------------
Perhaps you can try my code. Note that you must launch this rule from within a model sheet metal .IPT file only. It will not work if you to try launching with an IDW or a non sheet metal part IPT open.
Perhaps Autodesk can help out to define the proper access code to the Sheet Metal Flat Pattern View. Further, how to define to show Tangent Edges in a formed view.
Thank you for your efforts.
Raj