Blog · Inventor · 1 Oct 2026 · 3 min read
How to export DXF and PDF from Inventor with a script, and why SaveCopyAs fails
Batch export from Inventor drawings fails in ways that name nothing. The DXF translator needs an ini file, the PDF needs the right context and all colours set to black, and orphan documents kill the next export. A working VBScript and a table of failures.
Short answer: use the translator add-in with SaveCopyAs, not Document.SaveAs. For DXF, write an ini file first and point the translator at it, or it fails with Invalid procedure call or argument. For PDF, set the context type to 13059 and All_Color_AS_Black = 1, or the dimensions come out white on white.
DXF: the working pattern
Set inv = GetObject(, "Inventor.Application")
inv.SilentOperation = True
Set fso = CreateObject("Scripting.FileSystemObject")
' 1. the translator does not work without an ini file
iniPath = fso.BuildPath(fso.GetSpecialFolder(2), "inv_dxf_cfg.ini")
Set ts = fso.CreateTextFile(iniPath, True)
ts.WriteLine "[Choose INI Values]"
ts.WriteLine "Export_Acad_IniFile=" & iniPath
ts.WriteLine "[Export_Acad_Version]"
ts.WriteLine "Export_Acad_Version=2013"
ts.Close
' 2. the DXF translator add-in
Set dxf = inv.ApplicationAddIns.ItemById("{C24E3AC4-122E-11D5-8E91-0010B541CD80}")
' 3. context, options, output file
Set doc = inv.Documents.Open(idwPath, False)
Set ctx = inv.TransientObjects.CreateTranslationContext
ctx.Type = 13059 ' kFileBrowseIOMechanism
Set opts = inv.TransientObjects.CreateNameValueMap
dxf.HasSaveCopyAsOptions doc, ctx, opts ' fills opts with the defaults
opts.Value("Export_Acad_IniFile") = iniPath
Set dm = inv.TransientObjects.CreateDataMedium
dm.FileName = dxfPath
dxf.SaveCopyAs doc, ctx, opts, dm
doc.Close True ' close without saving
PDF: two settings that decide everything
- Context type
13059(kFileBrowseIOMechanism), as for DXF. With13075theSaveCopyAscalls fail with no error at all: no file, no message. All_Color_AS_Black = 1in the options. Without it, dimensions in a light colour come out white on a white page.
When the export fails
| Symptom | Cause | Fix |
|---|---|---|
DXF: Invalid procedure call or argument |
No ini file for the translator | Write the ini and pass Export_Acad_IniFile. |
| PDF: no file and no error | Context type 13075 |
Use 13059. |
| PDF: dimensions missing on the page | They are drawn white | All_Color_AS_Black = 1. |
Unspecified error on the second or third file |
Opening an .idw also opens its .ipt; closing the drawing leaves the model open |
After each file, close every document the script opened. |
| The script freezes on a file | A dialog is waiting for a click | SilentOperation = True before Open. |
| A drawing seems to stay open after you closed it | An open assembly holds its drawings in memory | Close the assembly too. |
| The disk fills up and Inventor crashes mid-run | Large batches | Check free space before starting. |
Checking what came out
An export that returns no error has not proved the file is right. After each batch:
- Count the files: one per drawing.
- Open each DXF with a script (in Python,
ezdxf) and check it has the entities you expect. - Render it to an image and look at it. Our rule: no DXF is declared done until someone has seen it as a picture.
The last step is not optional. A checking script once reported ALL OK on a drawing the client rejected in three seconds by opening it. More in Can AI read DXF files?.
Do and don't
Do
- Use
SaveCopyAsthrough the translator add-in. - Write the DXF ini file in the script, so the run does not depend on a file someone may delete.
- Close the model the drawing opened.
- Render the output and look at it.
Don't
- Don't save the drawing after exporting. Close it with
Close True. - Don't trust a missing error message as success.
- Don't run two batches against the same Inventor at the same time.
Questions people ask
Which DXF version should I export? Whatever your cutting software reads. We use 2013 in the ini file above.
Can I export flat patterns of sheet-metal parts the same way? The drawing export is the same. Creating the flat pattern from a STEP solid has its own traps: Inventor API errors and what they mean.
Can the same script run from an AI agent?
Yes. It is a .vbs file run with cscript from the terminal: how to drive Inventor without an MCP server.