Message 1 of 5
Export DXF on save Ilogic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello all,
I have found some code a while back that will create a DXF when I save a sheet metal file. I recently noticed though that if I am in an assembly and a sheet metal component needs saved, I get the following error. I am only firing the rule to run on save in the sheet metal components. This is an external rule.
Line 12 is:
oDoc = ThisApplication.ActiveDocument
I assume this has to deal with how the code is referencing documents. All i am wanting is the rule to run on the sheet metal parts only and if there are mods then make sure they are also run behind the scenes and not bark at me at an assembly level lol...
Here is the code:
SETFilePath = ThisDoc.Path Dim partDoc As PartDocument If ThisApplication.ActiveDocument.DocumentType <> kPartDocumentObject Then MessageBox.Show ("Please open a part document", "iLogic") End If 'Check for flat pattern >> create one if needed Dim oDoc As PartDocument oDoc = ThisApplication.ActiveDocument Dim oCompDef As SheetMetalComponentDefinition oCompDef = oDoc.ComponentDefinition If oCompDef.HasFlatPattern = False Then oCompDef.Unfold Else oCompDef.FlatPattern.Edit End If 'DXF Settings Dim sOut As String Dim sPATH As String 'sOut = "FLAT PATTERN DXF?AcadVersion=2000&OuterProfileLayer=IV_INTERIOR_PROFILES" sOut = "FLAT PATTERN DXF?AcadVersion=2000&OuterProfileLayer=IV_OUTER_PROFILE&InvisibleLayers=IV_TANGENT;IV_ROLL_TANGENT" Dim sFname As String sFname = SETFilePath & "\" & ThisDoc.FileName(False) & ".dxf" 'Export the DXF and fold the model back up oCompDef.DataIO.WriteDataToFile( sOut, sFname) Dim oSMDef As SheetMetalComponentDefinition oSMDef = oDoc.ComponentDefinition oSMDef.FlatPattern.ExitEdit
Thanks in advanced!
Autodesk Certified Professional