1

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)
3
  • 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, 2015 at 12:25
  • Convert to DWG and then covert cad files to feature class via "CAD to geodatabase" in batch mode
    – Navid
    Dec 30, 2015 at 12:35
  • I've edited the question and added the code which i've tried.
    – joseph_k
    Dec 31, 2015 at 13:10

1 Answer 1

2

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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