I have already explored some of the previous posts regarding this subject. They are close but don't quite fit what I need.
My current workflow is as follows:
What I'd like is an iLogic code which allows me to run the Save Copy As... command as shown below from within the .idw of the sheet metal part.
Thereby eliminating the need to open the .ipt separately in order to create the flat pattern (.dxf). Anyone have any ideas? I feel like the solution is relatively simple to an expert but I'm relatively new to iLogic.
Thanks!
Solved! Go to Solution.
Solved by Owner2229. Go to Solution.
Try this. It'll go through every part in the currently open drawing and export the flat pattern with the same name as the part.
Dim oDoc As Document = ThisApplication.ActiveDocument 'Get active document If oDoc.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub 'Drawings only For Each oModel As Document In oDoc.ReferencedDocuments 'Loop through all referenced documents
'Sheet metal parts only If oModel.DocumentSubType.DocumentSubTypeID <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then Continue For Dim oSMCD As SheetMetalComponentDefinition = oModel.ComponentDefinition If Not oSMCD.HasFlatPattern Then 'If it doesn't have a flat patter, create one (unfold the model) oSMCD.Unfold() oSMCD.FlatPattern.ExitEdit() End If Dim FName As String = oModel.FullFileName 'Get the document's path and name FName = Microsoft.VisualBasic.Left(FName, Len(FName) - 4) & ".dxf" Dim sOut As String = "FLAT PATTERN DXF?AcadVersion=R12" 'Export settings Try oSMCD.DataIO.WriteDataToFile(sOut, FName) 'Export Catch End Try Next
Works like a charm!! I'm still learning iLogic and at times I just get stuck. Thank you for this streamlined solution, it does exactly what I need it to do!
You're welcomed. Give it some time and you'll be able to code stuff like this from the top of your head.
Hi
I would like to use these code to export flat pattern to dxf. DXF files named as model part number should be saved in individual folders also named as model part number. Could it be done?
Can't find what you're looking for? Ask the community or share your knowledge.