I have a bunch of DXF files to import into ArcGIS 10 but they are all in mm. However I need to change the unit to Meter and to do this I have to open AutoCAD to do it each time. Can anyone help to write a script in Python to batch convert the unit of DXF from mm to m without going through openning AutoCAD? Then they can be added in Arcmap to create shapefiles out of them.

  • Are the cad files in the same general location, and projection? – Matthew Snape Jan 24 '12 at 11:48
  • Yes they are all in the same area and same projection. – Matt Jan 25 '12 at 3:46

You need to change $INSUNITS system variable inside dxf file from value 4 to 6. 4 are millimeters, 6 are meters. Because dxf is plain text file, you can easily read it and manipulate it as such.

I have tired to solve your problem with dxfwrite, but with no success. I could not successfully change that variable so that AutoCAD accepts modification.


You can easily write a batch file (.scr) to change your dxf files in AutoCad. I don't know the exact syntax but something like,

open file1.dxf INSUNIT 6 save
open file2.dxf INSUNIT 6 save

Then run the script in AutoCad. FYI, Autodesk has a free tool called ScriptPro that runs multiple commands on multiple drawings. Finally, you should be able to convert your DXF files to Shapefile using ogr2ogr or ArcPy.


A possible approach is to create world files. This defines mappings between your local coordinate system (in mm) into your target coordinate system (in metres). The format is well described in the ESRI help. Pick a pair of coordinates that will work for all your data. This can then be saved in esri_cad.wld which will be applied to all CAD files in the folder.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.