Actually, currently we are doing dgn -> shp file conversion using ogr2ogr. Batch convert dgn files to shp files using ogr2ogr

The problem is, at times the point layer is not getting read properly & few attributes are missing. But, if we convert the dgn using xxx.dgn -> Export -> To Shapefile (multiple) all the attributes of the features are getting retained and annotaion layer & point layer is getting saved separately.

But we are doing it file by file. Is it possible to run this as a batch using Arcpy ?

I've tried with the code given in this site https://geonet.esri.com/thread/56828

It work's perfectly. But the files are saved in a gdb. I want it to be saved as separate shapefiles.

import arcpy  
import glob  
import os  
gdb = "D:/Arc/new.gdb"  
arcpy.env.workspace = gdb  
arcpy.CreateFileGDB_management("D:/Arc", "new.gdb")  
reference_scale = "1500"  
for file in glob.glob(r"D:\Arc\*.dgn"): 
outDS = arcpy.ValidateTableName(os.path.splitext("d" + os.path.basename(file)) [0])  
arcpy.CADToGeodatabase_conversion(file, gdb, outDS, reference_scale)
  • 2
    Just about everything is possible through ArcPy. I recommend you make an attempt, and alter this question if you get stuck.
    – Vince
    Dec 30 '15 at 12:25
  • Convert to DWG and then covert cad files to feature class via "CAD to geodatabase" in batch mode
    – PredatorX
    Dec 30 '15 at 12:35
  • I've edited the question and added the code which i've tried.
    – joseph_k
    Dec 31 '15 at 13:10

Using python/arcpy you may use os.walk to iterate through a directory where you have many .dgn files and use Feature Class to Feature Class method to export the point, polyline, polygon...etc layers to shapefiles.

  • I would like to convert the files to separate Shapefile rather than Feature_Class.
    – joseph_k
    Dec 31 '15 at 15:56
  • feature class to feature class method does that.
    – artwork21
    Jan 1 '16 at 15:30

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.