If someone doesn’t answer this for you, I can tell you that I’m sort of working on the same thing. If I ever find the time to properly finish, I will gladly share my findings. Though this is somewhat unrelated, this is the code I use (while inside of an Assembly file (Top Level)) to go through all of the sheet metal parts.
Public Sub SheetmetalConverter()
Dim topDoc As Document
Set topDoc = ThisApplication.ActiveDocument
Dim doc As Document
For Each doc In topDoc.AllReferencedDocuments
Call ProcessDoc(doc, topDoc)
Next
End Sub
Sub ProcessDoc(docPD As Document, topDocPD As AssemblyDocument)
'To make sure it's not library or read only
If docPD.IsModifiable = True Then
'to make sure that it's a part and not anything else
If (docPD.DocumentType = kPartDocumentObject) Then
'to make sure that it's of the Sheet Metal subtype, and not a solid model
If (docPD.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}") Then
'place it in the drawing?
End If
End If
End If
End Sub
(Note : The above example, and other code in this post is all VBA, not iLogic)
Though that above code will only work if you run it while you’re in an assembly file, you may be able to modify it to query an assembly that is somehow associated with the drawing file.
The below code is how I’m currently getting a single flat pattern to get thrown onto the drawing sheet. It’s still in the elementary steps, so it’s just a hard coded path.
Option Explicit
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("D:\PATH\PART.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
(I believe I obtained that flat pattern code from around the forums, so, props to the person that made it!)
So if I don't find the time to make something automated and sexy, perhaps you can. Or at least, this might help you to get started working in a good direction.
If my solution worked or helped you out, please don't forget to hit the kudos button 🙂iLogicCode Injector:
goo.gl/uTT1IB