Community
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_PROFILE" oCompDef.DataIO.WriteDataToFile( sOut, oDataMedium.FileName) oCompDef.FlatPattern.ExitEdit Catch End Try oDrawDoc.Close Else End If Next
Can't find what you're looking for? Ask the community or share your knowledge.