• Blog posts

    Bio

    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

    CadlinePathProperty()

    Cadline()

    End Sub

     

    Sub CadlinePathProperty()

    Dim FilePATH As String = "FilePATH"

    customPropertySet = ThisDoc.Document.PropertySets.Item _

    ("Inventor User Defined Properties")

    Try

             prop= customPropertySet.Item(FilePATH)

    Catch

                customPropertySet.Add("", FilePATH)

    End Try

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

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

    Else

    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

         oCompDef.Unfold

        Else

        oCompDef.FlatPattern.Edit

        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

    oSMDef.FlatPattern.ExitEdit

    'This code has been adapted from http://www.cadlinecommunity.co.uk/Blogs/Blog.aspx?ScoId=

    '4733ef2d-cd48-4bd9-a280-1d88dbbf3556&returnTo=%2fBlogs%2fclintonbrown%2fDefault.aspx

    '&returnTitle=Clinton+Brown%20Blog

    End Sub

     

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