Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question
    
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
add comment

3 Answers 3

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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