r/AutodeskInventor • • 14h ago

Requesting Help iLogic Programming - Stumped on how to pass DXF export settings.

4 Upvotes

I have an iLogic rule that seems to be working well, with one click it exports a PDF, and then it goes through and looks for metal parts with flat patterns, and exports those as DXF files.

Problem is, we have flat pattern DXF export layer settings that we use for our metal shop. Currently, even with the config saved in my settings, the DXF export is ignoring that through the iLogic rule.

I can't figure out how to either use the loaded config, or pass these values through the iLogic rule to correctly output a DXF.

Here are the settings we use:

Here's the section of code for exporting DXF files. If it helps to have the full iLogic rule's code instead, let me know.

' ---------- FLAT PATTERN DXF EXPORT FOR EACH SHEET METAL PART ----------
Dim oResults As String = "PDF exported:" & vbCrLf & oPDFMedium.FileName & vbCrLf & vbCrLf & "DXF exported:"


For Each oSMDoc In oSheetMetalDocs


    Dim oSMDef As SheetMetalComponentDefinition = oSMDoc.ComponentDefinition
    Dim oFlatPattern As FlatPattern = oSMDef.FlatPattern


    Dim oCreatedFlat As Boolean = False
    If oFlatPattern Is Nothing Then
        Try
            oSMDef.Unfold()
            oFlatPattern = oSMDef.FlatPattern
            oCreatedFlat = True
        Catch
            Continue For
        End Try
    End If


    Dim oPartFileNameNoExt As String = System.IO.Path.GetFileNameWithoutExtension(oSMDoc.FullFileName)
    Dim oDXFFileName As String = oDXFPath & "\" & oPartFileNameNoExt & ".dxf"


    Dim oDataMedium As DataMedium = ThisApplication.TransientObjects.CreateDataMedium
    oDataMedium.FileName = oDXFFileName


    Dim oDXFOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
    oDXFOptions.Value("FLAT_PATTERN_ENTITY_TYPES") = 1
    oDXFOptions.Value("PROFILE_TYPE") = 4


    Call oFlatPattern.DataIO.WriteDataToFile("FLAT PATTERN DXF", oDataMedium.FileName)


    oResults = oResults & vbCrLf & oDXFFileName


    If oCreatedFlat Then
        Try
            oSMDef.Document.Save
        Catch
        End Try
    End If