Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CREATE FLAT PATTERN IDW FROM ASM

1 REPLY 1
Reply
Message 1 of 2
Anonymous
378 Views, 1 Reply

CREATE FLAT PATTERN IDW FROM ASM

I borrowed this code from here and it works great. i was wondering if it could be modified to generate flat pattern idw's as well.  any help is greatly appreciated. 

 

 

Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) -4)

If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then
MessageBox.Show("Please run this rule from the assembly file.", "iLogic")
Exit Sub
End If

RUsure = MessageBox.Show ( _
"This will create a DXF file for all of the asembly components that are sheet metal." _
& vbLf & "This rule expects that the part file is saved." _
& vbLf & " " _
& vbLf & "Are you sure you want to create DXF for all of the assembly components?" _
& vbLf & "This could take a while.", "iLogic - Batch Output DXFs ",MessageBoxButtons.YesNo)
If RUsure = vbNo Then
Return
Else
End If
oPath = ThisDoc.Path
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap

oFolder = oPath & "\" & oAsmName & " DXF Files"

If Not System.IO.Directory.Exists(oFolder) Then
System.IO.Directory.CreateDirectory(oFolder)
End If
'- - - - - - - - - - - - -
'- - - - - - - - - - - - -Component - - - - - - - - - - - -

Dim oRefDocs As DocumentsEnumerator
oRefDocs = oAsmDoc.AllReferencedDocuments
Dim oRefDoc As Document

For Each oRefDoc In oRefDocs
iptPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) - 3) & "ipt"

If(System.IO.File.Exists(iptPathName)) Then
Dim oDrawDoc As PartDocument
oDrawDoc = ThisApplication.Documents.Open(iptPathName, True)
oFileName = Left(oRefDoc.DisplayName, Len(oRefDoc.DisplayName))
Try


Try
CustomName =iProperties.Value(oFileName, "Custom", "PF_PRT_ZNR")
Catch
CustomName ="XXX" 
End Try

oDataMedium.FileName = oFolder & "\" & CustomName  & " " & oFileName & ".dxf"

Dim oCompDef As SheetMetalComponentDefinition
oCompDef = oDrawDoc.ComponentDefinition
If oCompDef.HasFlatPattern = False Then
oCompDef.Unfold
Else
oCompDef.FlatPattern.Edit
End If
Dim sOut As String
sOut = "FLAT PATTERN DXF?AcadVersion=2004&OuterProfileLayer=IV_OUTER_PR​OFILE"
oCompDef.DataIO.WriteDataToFile( sOut, oDataMedium.FileName)

oCompDef.FlatPattern.ExitEdit
Catch
End Try
oDrawDoc.Close
Else
End If
Next
1 REPLY 1
Message 2 of 2
Anonymous
in reply to: Anonymous

also it needs to use a company drawing template. thanks in advance.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report