Blog posts


by Clint Brown

At the recent CADline MFG Mater Class events, I showed how easy it was to automatically export DXF flat patterns from Inventor using iLogic.

In this blog post, I want to share some of the code I used, and I also wanted to show those users that are new to iLogic, how to get the rule working in their .ipt files.

The rule automatically creates a flat pattern of the part, saved to the same location as the current part. Note that the file MUST be saved before running the rule to avoid errors.

The first thing to do is to create a new sheet metal part. And to then get the iLogic browser up, this is done by clicking on the View Tab, then the User Interface Dropdown, and then by ticking iLogic Browser

In the top of your iLogic browser, right click on the part name, and then select “Add Rule”

Give the rule a name

Then paste the code below into the  rule and close the dialogue box. As soon as you do this, the rule will run.

Copy and paste all of the code between the lines (Sub Main to End Sub)

Sub Main

DefaultChoice = True



End Sub


Sub CadlinePathProperty()

Dim FilePATH As String = "FilePATH"

customPropertySet = ThisDoc.Document.PropertySets.Item _

("Inventor User Defined Properties")


         prop= customPropertySet.Item(FilePATH)


            customPropertySet.Add("", FilePATH)

End Try

If iProperties.Value("Custom", "FilePATH") = "" Then

iProperties.Value("Custom", "FilePATH") = "C:\"


End If

Dim partDoc As PartDocument

If ThisApplication.ActiveDocument.DocumentType <> kPartDocumentObject Then

MessageBox.Show ("Please open a part document", "iLogic")

End If

FilePATH = InputBox("Enter a FilePATH for part file", "iLogic", iProperties.Value("Custom", "FilePATH"))

iProperties.Value("Custom", "FilePATH") = FilePATH

End Sub


Public Sub Cadline()

    Dim oDoc As PartDocument

    oDoc = ThisApplication.ActiveDocument

    Dim oCompDef As SheetMetalComponentDefinition

    oCompDef = oDoc.ComponentDefinition

     If oCompDef.HasFlatPattern = False Then




    End If

    Dim sOut As String

    Dim sPATH As String

    sPATH = iProperties.Value("Custom", "FilePATH")

    sOut = "FLAT PATTERN DXF?AcadVersion=2000&OuterProfileLayer=IV_INTERIOR_PROFILES"

    Dim sFname As String

    sFname = sPATH & "\" & ThisDoc.FileName(False) & ".dxf"

    MessageBox.Show("DXF SAVED TO: " & sFname ,"DXF Saved", MessageBoxButtons.OK)

    oCompDef.DataIO.WriteDataToFile( sOut, sFname)

  oDoc = ThisApplication.ActiveDocument

Dim oSMDef As SheetMetalComponentDefinition

oSMDef = oDoc.ComponentDefinition


'This code has been adapted from



End Sub


Any time you want to run the rule again, right click on it and select Run Rule