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.
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.