[GIS] Batch convert dgn files to separate shapefiles in ArcGIS

arcgis-desktoparcpydgn

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)

Best Answer

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.

Related Question