Automate ipart flat pattern export to dxf

Automate ipart flat pattern export to dxf

dan_goodrich89
Explorer Explorer
1,902 Views
6 Replies
Message 1 of 7

Automate ipart flat pattern export to dxf

dan_goodrich89
Explorer
Explorer

I'm trying to modify Clint Browns Automate DXF Flat Patterns iLogic code to run through all ipart members and export dxfs https://clintbrown.co.uk/2018/12/09/dxf/

 

It works on the active iPart, adjusting the code to name the dxf using the ipart number, but I'm struggling with looping it though all iPart members.

 

 

0 Likes
Accepted solutions (1)
1,903 Views
6 Replies
Replies (6)
Message 2 of 7

JelteDeJong
Mentor
Mentor
Accepted solution

does this work for you?

Dim doc As PartDocument = ThisDoc.Document

If (doc.ComponentDefinition.IsiPartFactory = False) Then
    MsgBox("This is not an iPart factory")
End If

Dim fact As iPartFactory = doc.ComponentDefinition.iPartFactory
For Each row As iPartTableRow In fact.TableRows
    fact.DefaultRow = Row
    doc.Update()
    doc.Update2(False)

    Dim oCompDef As SheetMetalComponentDefinition = doc.ComponentDefinition
    If oCompDef.HasFlatPattern = False Then
        oCompDef.Unfold()
    Else
        oCompDef.FlatPattern.Edit
    End If

    'DXF Settings
    Dim sOut As String
    sOut = "FLAT PATTERN DXF?AcadVersion=2000&OuterProfileLayer=IV_INTERIOR_PROFILES"
    Dim sFname As String = "c:\temp\" & ThisDoc.FileName(False) & "_" & Row.MemberName & ".dxf"

    'Export the DXF and fold the model back up
    oCompDef.DataIO.WriteDataToFile(sOut, sFname)
    oCompDef.FlatPattern.ExitEdit()
Next

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 3 of 7

dan_goodrich89
Explorer
Explorer

Works perfectly, thank you!

0 Likes
Message 4 of 7

Anonymous
Not applicable

First and foremost thank you for the great piece of code you have provided here.

 

I am trying to do something similar, I made a recent forum post about it, for reference:

https://forums.autodesk.com/t5/inventor-customization/ilogic-code-to-export-all-iparts-as-dxf-or-dwg...

 

But I tried your code on a flat pattern drawing. It went through all the iParts and seemed like it was saving it or doing something since it went through each and every single drawing, however I cannot find where these files ended up... Code ran flawlessly no errors.

0 Likes
Message 5 of 7

aurel_e
Collaborator
Collaborator

Have you looked at   "c:\temp\" ?

0 Likes
Message 6 of 7

KrishR330
Contributor
Contributor
Dim sFname As String = "c:\temp\" & ThisDoc.FileName(False) & "_" & Row.MemberName & ".dxf"

 

I am trying to name the DXF file with values of few custom parameters of my iPart file instead of Row.MemberName.  Can you help change the code accordingly?

 

 Thanks and Regards,

Krish

0 Likes
Message 7 of 7

floccipier
Advocate
Advocate

@JelteDeJong brilliant as always. thanks for this simple and effective code.

0 Likes