I am working on a new iLogic rule that will create and IDW with automate views of the folded model of the sheet metal part in front view, right view, top view and the flat pattern I have success with all views except the flat pattern view creation codes. Does anyoone have knowledge of what the code terminology is to add a flat pattern view through ilogic to an idw?
Also, if this is possible, I want to create a bend table and a hole table using ilogic to automate these processes.
So far, I can create any view off the folded model but I do not know the code to create a flat pattern view.
Please help.
I don't remember where I found this code, but at one time I had the same question.
I hope that this helps!
Public Sub AddFlatPatternDrawingView() ' Set a reference to the drawing document. ' This assumes a drawing document is active. Dim oDrawDoc As DrawingDocument Set oDrawDoc = ThisApplication.ActiveDocument 'Set a reference to the active sheet. Dim oSheet As Sheet Set oSheet = oDrawDoc.ActiveSheet ' Create a new NameValueMap object Dim oBaseViewOptions As NameValueMap Set oBaseViewOptions = ThisApplication.TransientObjects.CreateNameValueMap ' Set the options to use when creating the base view. Call oBaseViewOptions.Add("SheetMetalFoldedModel", False) ' Open the sheet metal document invisibly Dim oModel As Document Set oModel = ThisApplication.Documents.Open("C:\Some\Crazy\Path\To\Your\Part\Here.ipt", False) ' Create the placement point object. Dim oPoint As Point2d Set oPoint = ThisApplication.TransientGeometry.CreatePoint2d(0, 0) ' Create a base view. Dim oBaseView As DrawingView Set oBaseView = oSheet.DrawingViews.AddBaseView(oModel, oPoint, 1, _ kDefaultViewOrientation, kHiddenLineRemovedDrawingViewStyle, _ , , oBaseViewOptions) End Sub
That code was for VBA and not ilogic. I will try to make some ilogic code for you tomorrow (or later today if I have time).
Did you ever get this to work? If so could you please post it as I would also like to get this to work.
Thanks in advance.
I'm not sure if this will work for 2012, but this is the sample provided by 2019 Inventor:
SyntaxEditor Code Snippet
' Set a reference to the drawing document. ' This assumes a drawing document is active. Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.ActiveDocument 'Set a reference to the active sheet. Dim oSheet As Sheet oSheet = oDrawDoc.ActiveSheet ' Create a new NameValueMap object Dim oBaseViewOptions As NameValueMap oBaseViewOptions = ThisApplication.TransientObjects.CreateNameValueMap ' Set the options to use when creating the base view. oBaseViewOptions.Add("SheetMetalFoldedModel", False) ' Open the sheet metal document invisibly Dim oModel As Document oModel = ThisApplication.Documents.Open("C:\temp\SheetMetal.ipt", False) ' Create the placement point object. Dim oPoint As Point2d oPoint = ThisApplication.TransientGeometry.CreatePoint2d(25, 25) ' Create a base view. Dim oBaseView As DrawingView oBaseView = oSheet.DrawingViews.AddBaseView(oModel, oPoint, 1, _ kDefaultViewOrientation, kHiddenLineRemovedDrawingViewStyle, , , oBaseViewOptions)
Basically at the end of the Add Base View command there's a section for adding additional options specific to sheet metal, weldments, iPart/iAssembly, Positional, and Presentation views. As you see in the middle of the sample it creates a Name Value Map and adds the option of SheetMetalFolded=False, then that argument is used in the drawing view creation where False means Flat.
You just needed to create the NameValueMap and assign the correct variable. You were very close.
Note: Per the 2017 API guide, this will only place the flat view, if it already exists in the part. If it does not exist, then it will place a folded view.
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) ' Create a new NameValueMap object Dim oBaseViewOptions As NameValueMap oBaseViewOptions = ThisApplication.TransientObjects.CreateNameValueMap ' Set the options to use when creating the base view. oBaseViewOptions.Add("SheetMetalFoldedModel", False) '-----------------------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, , ,oBaseViewOptions) End If