- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I'm trying to export as dxf from parts; however, my script includes the tangent lines when exported, which means there are 3 bend lines instead of one. I want to turn off the IV_TANGENT and IV_ROLL_TANGENT layers.
My code is below.
```
Sub ExportFlatPatternToDXF2()
Dim SETFilePath As String
SETFilePath = "path"
If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then
MsgBox "Please open an assembly document.", vbExclamation, "iLogic"
Exit Sub
End If
Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = ThisApplication.ActiveDocument
Dim oRefDocs As DocumentsEnumerator
Set oRefDocs = oAsmDoc.AllReferencedDocuments
Dim oRefDoc As Document
For Each oRefDoc In oRefDocs
If oRefDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
Dim oSheetMetDoc As PartDocument
Set oSheetMetDoc = ThisApplication.Documents.Open(oRefDoc.FullFileName, True)
Dim oCompDef As SheetMetalComponentDefinition
Set oCompDef = oSheetMetDoc.ComponentDefinition
Dim oDef As FlatPattern
' If oCompDef.HasFlatPattern = False Then
' oCompDef.Unfold
' End If
Set oDef = oCompDef.FlatPattern
If oDef Is Nothing Then GoTo NextOcc
Dim sOut As String
sOut = "FLAT PATTERN DXF?AcadVersion=2018&OuterProfileLayer=IV_INTERIOR_PROFILES"
Dim sFname As String
sFname = SETFilePath & "\" & oSheetMetDoc.DisplayName & ".dxf"
Dim oDataIO As DataIO
Set oDataIO = oCompDef.DataIO
oDataIO.WriteDataToFile sOut, sFname
oCompDef.FlatPattern.ExitEdit
End If
NextOcc:
Next oRefDoc
MsgBox "Flat patterns exported to " & SETFilePath, vbInformation, "iLogic"
End Sub
```
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi! Another way to do it without using an iLogic rule is to save the seeing as a configuration. Turn off the layers and save the configuration (at the top of the dialog). Keep using the same cfg file and those layers will be turned off.
Many thanks!

Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @mindaV3J2J
I think you just need to update your sOut line to something like this:
Dim sOut As String sOut = "FLAT PATTERN DXF?AcadVersion=2007" & _ "&OuterProfileLayer=IV_INTERIOR_PROFILES" & _ "&InvisibleLayers = IV_TANGENT;IV_ROLL_TANGENT"
Reference link:
https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=WriteFlatPatternAsDXF_Sample
related link:
And here is an example of all options, just for reference:
Dim sOut As String sOut="FLAT PATTERN DXF?AcadVersion=2007" & _ "&TangentLayer=IV_TANGENT " & _ "&BendLayer=IV_BEND" & _ "&BendDownLayer=IV_BEND_DOWN" & _ "&ToolCenterLayer=IV_TOOL_CENTER" & _ "&ToolCenterDownLayer=IV_TOOL_CENTER_DOWN" & _ "&ArcCentersLayer=IV_ARC_CENTERS" & _ "&OuterProfileLayer=IV_OUTER_PROFILE" & _ "&InteriorProfilesLayer=IV_INTERIOR_PROFILES" & _ "&FeatureProfilesLayer=IV_FEATURE_PROFILES" & _ "&FeatureProfilesDownLayer=IV_FEATURE_PROFILES_DOWN" & _ "&AltRepFrontLayer=IV_ALTREP_FRONT" & _ "&AltRepBackLayer=IV_ALTREP_BACK" & _ "&UnconsumedSketchesLayer=IV_UNCONSUMED_SKETCHES" & _ "&TangentRollLinesLayer=IV_ROLL_TANGENT" & _ "&RollLinesLayer=IV_ROLL" & _ "&InvisibleLayers=IV_TANGENT;IV_ROLL_TANGENT" & _ "&TangentLayerColor=0;0;0 " & _ "&endLayerColor=255;0;0" & _ "&BendDownLayerColor=0;255;0" & _ "&ToolCenterLayerColor=0;0;0" & _ "&ToolCenterDownLayerColor=0;0;0" & _ "&ArcCentersLayerColor=0;0;0" & _ "&OuterProfileLayerColor=0;0;0" & _ "&InteriorProfilesLayerColor=0;0;0" & _ "&FeatureProfilesLayerColor=0;0;0" & _ "&FeatureProfilesDownLayerColor=0;0;0" & _ "&AltRepFrontLayerColor=0;0;0" & _ "&AltRepBackLayerColor=0;0;0" & _ "&UnconsumedSketchesLayerColor=-255;-255;-255" & _ "&TangentRollLinesLayerColor=0;0;0" & _ "&RollLinesLayerColor=0;0;0" & _ "&MergeProfilesIntoPolyline=True"
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi!
Thanks so much. However, when i run this, im getting an invalid procedure call or argument error, runtime error 5. Do you know why this is?
Thanks so much
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Actually, it outputted correctly i just changed the acad version to match mine; however, the tangent lines are still there. Any other ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @mindaV3J2J
Ahh, I was just trying to match what you had in the original example as far as ACAD version, but goofed that up. You are correct there is no 2008 version ( I updated my examples).
I just did a quick test and see the same results as you. I'll see if I can figure out what the issue is. It's likely a syntax issue with the sOut line.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
@mindaV3J2J , I had extra spaces in the sOut line that was causing the issue. I'll update my previous posts so it doesn't trip someone else up in the future.
Try this:
Dim sOut As String
sOut = "FLAT PATTERN DXF?AcadVersion=2007" & _
"&OuterProfileLayer=IV_INTERIOR_PROFILES" & _
"&InvisibleLayers=IV_TANGENT;IV_ROLL_TANGENT"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Sorry last question and this is unrelated, is there a way i can get this to loop through multiple inventor assembly files and pirnt the dxfs of each assembly rather than just the one using VBA. I assume we will have to use visual basic for this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
@mindaV3J2J wrote:
Sorry last question and this is unrelated, is there a way i can get this to loop through multiple inventor assembly files and pirnt the dxfs of each assembly rather than just the one using VBA. I assume we will have to use visual basic for this.
yeah, you can probably do this.
How are you identifying the assemblies?
Are they all in the same folder? All open in Inventor? Something else?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
yes they're all in the same folder. My coworker would like to be able to drop multiple assemblies in the same folder and output the respective flat parts in individual folders corresponding to the assembly it came from. thanks so much for your help as well
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This VBA example will open all the assemblies in a folder, and then close them. Add your DXF code where indicated.
Sub FindFilesWithComment()
sName = ThisApplication.ActiveDocument.FullFileName
Dim filesystem As Object
Set filesystem = CreateObject("Scripting.FilesystemObject")
Dim ActiveDoc As Document
Set ActiveDoc = ThisApplication.ActiveDocument
Dim FolderPath As String
FolderPath = BrowseForFolder()
If FolderPath = "" Then Exit Sub
Dim oFSO As Object
Dim oFolder As Object
Dim oFile As Object
Dim oFiles As Object
Dim oFileNames As String
oFileNames = "Files with comments: " & oComment
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(FolderPath)
For Each oFile In oFolder.Files
If LCase(oFSO.GetExtensionName(oFile.Name)) = "iam" Then
sFilename = FolderPath & "\" & oFile.Name
Dim oAsmDoc As AssemblyDocument
'set option to false to open invisible and run faster
Set oAsmDoc = ThisApplication.Documents.Open(sFilename, True)
MsgBox (oAsmDoc.FullFileName)
Dim oRefDocs As DocumentsEnumerator
Set oRefDocs = oAsmDoc.AllReferencedDocuments
Dim oRefDoc As Document
For Each oRefDoc In oRefDocs
'put your DXF code here
Next oRefDoc
If Not ActiveDoc Is oAsmDoc Then oAsmDoc.Close (True) 'true = skip save
End If
Next oFile
End Sub
Function BrowseForFolder(Optional OpenAt As Variant) As Variant
Dim ShellApp As Object
Set ShellApp = CreateObject("Shell.Application"). _
BrowseForFolder(0, "Please choose a folder", 0, OpenAt)
On Error Resume Next
BrowseForFolder = ShellApp.self.Path
On Error GoTo 0
Set ShellApp = Nothing
Select Case Mid(BrowseForFolder, 2, 1)
Case Is = ":"
If Left(BrowseForFolder, 1) = ":" Then GoTo Invalid
Case Is = "\"
If Not Left(BrowseForFolder, 1) = "\" Then GoTo Invalid
Case Else
GoTo Invalid
End Select
Exit Function
Invalid:
BrowseForFolder = ""
End Function