Hello,
I attached the iLogic code which is automatically creating dwg drawing (script borrowed from one of the discussion group users), also it creates 4 views. I`m just wondering how to add flat pattern ?
Thanks,
Alex.
Solved! Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Solved by achmidt. Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Hi achmidt,
Here is a variation of your rule that places a flat pattern in the default orientation. See attached .txt file if copying and pasting the code directly causes issues.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Imports Inventor.ViewOrientationTypeEnum Imports Inventor.DrawingViewStyleEnum Dim oDrawingDoc as DrawingDocument Dim oPartDoc as Document Dim oSheet As sheet Dim oView1 as DrawingView Dim oView2 as DrawingView Dim oView3 as DrawingView Dim oView4 as DrawingView ViewScale = 1 '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, "C:\Temp\my template.idw", True) oDrawingDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "", True) oSheet = oDrawingDoc.Sheets.Item(1) ' Create a new NameValueMap object Dim oBaseViewOptions As NameValueMap oBaseViewOptions = ThisApplication.TransientObjects.CreateNameValueMap 'True = folded view 'False = flat pattern view oBaseViewOptions.Add("SheetMetalFoldedModel", False) 'Define 2d view bottom left corner points for four views oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(9, 10) ' front view oPoint2 = ThisApplication.TransientGeometry.CreatePoint2d(9, 14) ' top view oPoint3 = ThisApplication.TransientGeometry.CreatePoint2d(18, 10)' right view oPoint4 = ThisApplication.TransientGeometry.CreatePoint2d(20, 18)' flat pattern oBaseView = oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint1, ViewScale,kFrontViewOrientation, kHiddenLineDrawingViewStyle, "My View") oView2 = oSheet.DrawingViews.AddProjectedView(oBaseView,oPoint2, kHiddenLineDrawingViewStyle, ViewScale) oView3 = oSheet.DrawingViews.AddProjectedView(oBaseView,oPoint3, kHiddenLineDrawingViewStyle, ViewScale) 'kDefaultViewOrientation = 10753 (default folded or flat pattern view) 'kFlatPivotRightViewOrientation = 10767 'kFlatPivotLeftViewOrientation = 10768 'kFlatPivot180ViewOrientation = 10769 'kFlatBacksideViewOrientation = 10770 'kFlatBacksidePivotRightViewOrientation = 10771 'kFlatBacksidePivotLeftViewOrientation = 10772 'kFlatBacksidePivot180ViewOrientation = 10773 oView4 = oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint4, ViewScale,kDefaultViewOrientation, kHiddenLineDrawingViewStyle,,, oBaseViewOptions) End If
Hi achmidt,
Here's another variation that checks the model to see if it is a sheetmetal part and then checks for a flat pattern and then generates one if it doesn't find it.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Imports Inventor.ViewOrientationTypeEnum
Imports Inventor.DrawingViewStyleEnum
Dim oDrawingDoc as DrawingDocument
Dim oPartDoc as Document
Dim oSheet As sheet
Dim oView1 as DrawingView
Dim oView2 as DrawingView
Dim oView3 as DrawingView
Dim oView4 as DrawingView
ViewScale = 1
'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
'Check to see if part is a sheetmetal part
If oPartDoc.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
'do nothing
Else
'ensure this part has a flat pattern
Dim oSMDef As SheetMetalComponentDefinition
oSMDef = oPartDoc.ComponentDefinition
If oSMDef.FlatPattern Is Nothing Then
'create flat pattern
oSMDef.Unfold
oSMDef.FlatPattern.ExitEdit
Else
'do nothing
end if
End if
'Define IDW Template File Location
'oDrawingDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "C:\Temp\my template.idw", True)
oDrawingDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "", True)
oSheet = oDrawingDoc.Sheets.Item(1)
' Create a new NameValueMap object
Dim oBaseViewOptions As NameValueMap
oBaseViewOptions = ThisApplication.TransientObjects.CreateNameValueMap
'True = folded view
'False = flat pattern view
oBaseViewOptions.Add("SheetMetalFoldedModel", False)
'Define 2d view bottom left corner points for four views
oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(9, 10) ' front view
oPoint2 = ThisApplication.TransientGeometry.CreatePoint2d(9, 14) ' top view
oPoint3 = ThisApplication.TransientGeometry.CreatePoint2d(18, 10)' right view
oPoint4 = ThisApplication.TransientGeometry.CreatePoint2d(20, 18)' flat pattern
oBaseView = oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint1, ViewScale,kFrontViewOrientation, kHiddenLineDrawingViewStyle, "My View")
oView2 = oSheet.DrawingViews.AddProjectedView(oBaseView,oPoint2, kHiddenLineDrawingViewStyle, ViewScale)
oView3 = oSheet.DrawingViews.AddProjectedView(oBaseView,oPoint3, kHiddenLineDrawingViewStyle, ViewScale)
oView4 = oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint4, ViewScale,kDefaultViewOrientation, kHiddenLineDrawingViewStyle,,, oBaseViewOptions)
End If
Thanks a lot! Code worked. Attached is final iLogic script for creating 4 views and a flat pattern. I`ll have a lot more to do. Now I need to add overall dimensions, measure hole diameter, add ordinate dim`s for the baffle holes....
Curtis, I`m just wondering where to get all these API functions and descriptions of these variables? Is there any book? I searched internet and I couldn`t find anything for the inventor API.
Thanks,
Alex.
Hi achmidt,
Thanks for posting back your finished code. I'm certain it'll help someone in the future.
I think you should be able to find the Autodesk Inventor API Help file installed on your machine at some location like:
C:\Program Files\Autodesk\Inventor 20xx\Help
Look for a file named admapi_xx_0.chm
where the xx is the inventor version.
Edit:
See this link for better directions to the location of the .chm file
Also see this link:
http://usa.autodesk.com/adsk/servlet/index?id=1079044&siteID=123112
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Curtis,
Quick question,
how to change the line below so flat pattern reflects the bends? I assume kHiddenLineDrawingViewStyle needs to be replaced with a different statement?
oView4 = oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint4, ViewScale,kDefaultViewOrientation, kHiddenLineDrawingViewStyle,,, oBaseViewOptions)
Also is it possible and how to change drawing template so bend extents is checked by default?
Thank you so much!
Alex.
Hi Curtis,
which is the individual snippet that only search and in case generate the flat pattern in the sheet metal part?
Thank you!!
I know this is a really old post, but do you have a version of this that works in newer versions of inventor.
The above codes work in the latest version too.
And I am looking for an option to name all the views all in the same code
something like this
oView5.Label.FormattedText = "ISOMETRIC VIEW"
though i am not getting any error but the name is not getting changed as well.
can somebody help me ??
Note: I don't want to use orient type function as its naming my flat pattern as front view
Your code is really nice and helpful.
I have one query regarding the scaling. Can we make the code with a prompt box that will ask users to enter for the scale as well?
Thank you in advance
How do i make a drawing temp for this to work?
I have drawing temp but it dosent seen to work. please see attached Error
Thanks in advance.