Message 1 of 4

Not applicable
05-11-2021
02:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
'Define the active document as an assembly file Dim oDoc As Document = ThisApplication.ActiveDocument 'Check that the active document is an assembly file If oDoc.DocumentType <> kAssemblyDocumentObject Then MessageBox.Show("Please run this rule from the assembly file.", "iLogic") Exit Sub End If 'Get user input 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 <> vbYes Then Exit Sub Dim oAsmName As String = Left(oDoc.DisplayName, Len(oDoc.DisplayName) - 4) Dim oPath As String = ThisDoc.Path 'Get the DXF target folder path Dim oFolder As String = oPath & "\" & oAsmName & " DXF Files" 'Check for the DXF folder and create it if it does not exist If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If '- - - - - - - - - - - - -Component - - - - - - - - - - - - Dim oBOM As BOM = oDoc.ComponentDefinition.BOM oBOM.StructuredViewEnabled = True 'You'll have to play with this to get the BOM you want. Try 1, 2, 3 or "Structured" Dim oBOMView As BOMView = oBOM.BOMViews.Item(2) For Each oRow As BOMRow In oBOMView.BOMRows Dim oCD As ComponentDefinition = oRow.ComponentDefinitions.Item(1) Dim iDoc As Document = oCD.Document 'SheetMetal parts only If iDoc.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then Continue For Dim iName As String = iDoc.FullFileName 'check that model is saved If iName = vbNullString Then Continue For iDoc = ThisApplication.Documents.Open(iName) oCD = iDoc.ComponentDefinition Dim oItem As String = oRow.ItemNumber 'here I would like to change the rule Try If Not oCD.HasFlatPattern Then oCD.Unfold() Else oCD.FlatPattern.Edit() End If Dim sOut As String = "FLAT PATTERN DXF?AcadVersion=2004&OuterProfileLayer=IV_OUTER_PROFILE" 'Dim oDXFName As String = oPath & "\" & oAsmName & i & "_FlatPatterns.dxf" oCD.DataIO.WriteDataToFile(sOut, oFolder & "\" & oAsmName & "-" & oItem & ".dxf") oCD.FlatPattern.ExitEdit() MsgBox(oFolder & "\" & oAsmName & "-" & oItem & ".dxf") Catch ex As Exception MsgBox(ex.Message) End Try iDoc.Close(True) Next
Hi,
I found program, which export Flatpattern to DXF from assembly : https://forums.autodesk.com/t5/inventor-customization/export-flatpattern-to-dxf-from-assembly-filena...
I can't change the name of the saved file. I'd like it had a name like Item Number from iproperties.
Solved! Go to Solution.