iLogic: Export Flat Patterns of iPart Members to DXF

By Bhavik Suthar

I have written an iLogic utility to export the flat patterns of all the members of an iPart to DXF. The code automates the process of creating DXF flat patterns, saving the DXF with the instance member name as the file name in the same location as the original iPart.

Here is the iLogic Code:

'iLogic code By Bhavik Suthar 
'Originally posted on https://clintbrown.co.uk

Dim oDoc As PartDocument = ThisApplication.ActiveDocument
Dim oDef As SheetMetalComponentDefinition = oDoc.ComponentDefinition

Dim oPartMember As iPartMember

For Each oTab As iPartTableRow In oDef.iPartFactory.TableRows

MessageBox.Show(oTab.MemberName, "Name of the Member")

iPart.ChangeRow("", oTab.MemberName)

Dim oFeat As PartFeature
For Each oFeat In oDef.Features

	If oDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then

	If oDef.HasFlatPattern = False Then
		oDef.Unfold
	Else
		oDef.FlatPattern.Edit
	End If

	Dim odxf As String
	Dim oPath As String

	oPath = ThisDoc.Path & "\DXF" 

	If Not System.IO.Directory.Exists(oPath) Then
		System.IO.Directory.CreateDirectory(oPath)
	End If

	Dim odxfname As String

	odxf = "FLAT PATTERN DXF?OuterProfileLayer=0&OuterProfileLayerColor=0;0;0&InteriorProfilesLayer=0&InteriorProfilesLayerColor=0;0;0&BendDownLayerLineType=37633&BendDownLayerColor=0;0;255&BendUpLayerLineType=37633&BendUpLayerColor=0;0;255IV_BEND;IV_BEND_DOWN;IV_OUTER_PROFILE;IV_INTERIOR_PROFILES;IV_FEATURE_PROFILES;IV_FEATURE_PROFILES_DOWN;IV_ALTREP_FRONT;IV_ALTREP_BACK;IV_ROLL_TANGENT;IV_ROLL&InvisibleLayers=IV_TANGENT;IV_TOOL_CENTER;IV_TOOL_CENTER_DOWN;IV_ARC_CENTERS;IV_UNCONSUMED_SKETCHES" _
		+ "&RebaseGeometry=True" _
		+ "&SimplifySplines=True" _
		+ "&SplineTolerance=0.01" _
		
	odxfname = oPath & "\"& oTab.MemberName & ".dxf"
	oDef.DataIO.WriteDataToFile(odxf, odxfname)
	oDef.FlatPattern.ExitEdit
	
	MessageBox.Show("DXF has been saved in this location: " + odxfname)
	Else
	MessageBox.Show("There must be a sheetmetal component to get the dxf file!")
	End If

Next

Next

Below is a video showing how the code works:

Notes:

This version of the code was briefly tested in Inventor 2021.

As always, please test all iLogic code extensively on non-production files. Do not use any code in a production environment until YOU have thoroughly tested it and have verified that it works as expected. Always back up any data before running any experimental code. You are ultimately responsible for any iLogic code that you run, so make sure you test it thoroughly!

Bio: Bhavik Suthar has been using Inventor, AutoCAD and Vault since 2013. He has a good command of Solidworks and Creo. Bhavik works for a company that creates food, pharma, marine and dairy processing plants and equipment. He has spent 9+ years working in Mechanical Projects – Design Development with expertise in Static and Rotating equipment. In his current role, Bhavik creates automated models and drawings using Inventor and iLogic (alongside regular projects).

LinkedIn: https://www.linkedin.com/in/bhavikpsuthar/

Comments are closed.

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: