Simple iLogic DXF Exporter

@ClintBrown3D Autodesk Inventor dxf export


I wrote some iLogic code which allows a user to automatically export any face in an Inventor Part or Assembly file to DXF. The code allows the user to predefine a file name and path. The animated GIF below shows how the code works.

dxf exporter

There is one “glitch”, this code will export out flat and curved (projected) faces too.

For the geeks out there, here is a bit more info on how it all works.

I have been interested in the idea of using tool-tips with iLogic for a while now, my previous iLogic blog post looked at displaying iProperties of parts inside of an Assembly file.

I wanted to create a useful tool that exports a selected face to DXF. Currently a user can right-click on any face (while in a .ipt), and then export it to DXF via the user interface (see my blog post here).

Initially I was unable to find a reference to the DXF export in the Inventor API, but after a quick internet search, my suspicion was confirmed, the workaround is to use the “Command Manager”, which is essentially the same as clicking a button in the interface. For more on the “Command Manager”, have a look at this Autodesk blog post.

The code I have shared below, uses the same “Mouse Input” code that I used in the iProperties post, with the DXF export via the “Command Manager”, courtesy of the forum post shared in the code.

I’ve set the code up, so that it is easy to change the file path and file name, as you may with to adapt the code to suit your environment.

SetTheFilePathHere = "C:\Temp"
SetTheFilenameHere = ThisDoc.FileName(False)

Here is the code:

'Code By @ClintBrown3D
'Originally posted at
'Mouse input code based on this forum post:
'Additonal DXF info via '

SetTheFilePathHere = "C:\Temp"
SetTheFilenameHere = ThisDoc.FileName(False) 'without extension

Error0 = 1
On Error GoTo error1
ThisApplication.StatusBarText = "Select a Face to Export as DXF : @ClintBrown3D"
Dim doc = ThisApplication.ActiveDocument
Dim entity = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select a Face to Export as DXF : @ClintBrown3D")

ThisApplication.CommandManager.PostPrivateEvent(kFileNameEvent, SetTheFilePathHere &"\" & SetTheFilenameHere & ".dxf")

ThisApplication.StatusBarText = "Exporting your DXF, please hold : @ClintBrown3D"
Dim oCtrlDef As ButtonDefinition
oCtrlDef = 
Error0 = 0
MessageBox.Show("Success! - DXF exported", "@ClintBrown3D - DXF Export")
ThisApplication.StatusBarText = "Success! - DXF exported : @ClintBrown3D"

error1 :
If Error0 = 1 Then
MessageBox.Show("iLogic Rule Cancelled", "@ClintBrown3D - DXF Export")
End If


Comments are closed.

Create a website or blog at

Up ↑

%d bloggers like this: