Automating the extraction of boundary lines and annotations from CAD .DWG

07-29-2021 07:17 AM
New Contributor II

I work for a local government that will occasionally receive digital plats in the near future. The overarching goal is to extract the parcel lines and annotations from the CAD .DWG digital drawing and then ultimately append the annotations to our own annotations layer that's in production. 

I started writing a script that works with one .DWG; however, it does not work for every .DWG because there is not a standardization among field values in the field that I used to extract this data. And that is the problem I have encountered.

The script I previously wrote first converts the .DWG to a Geodatabase, which breaks down the CAD drawing into Annotation, MultiPatch, Point, Polygon, and Polyline layers. I extract the parcel boundary lines by querying the Polyline layer where 'Layer' == 'BOUNDARY' (field value). Then I extract out particular field values that will later be used for annotations. The first one is done by querying the Annotation layer where 'Layer' == "BOUNDARY' (field value) and the second one is done by querying the Annotation layer where 'Layer' == 'BRGTXT' (field value). 

This method works wonders when these field values such as BOUNDARY and BRGTXT exist within the CAD .DWG; however, when not all of the CAD .DWG's have the same field values that correspond to particular features (such as parcel boundary is where Polyline's 'Layer' value == "BOUNDARY"), this script design will not work. 

Is there another way to make this script work with all digital CAD .DWGs if there is not a standardization among the CAD .DWGs? If there is another method, any help will be very much appreciated. Thank you!

0 Kudos
2 Replies
Regular Contributor

It would probably help to see what your current codes looks like.

0 Kudos
Regular Contributor
import arcpy 
from arcpy import env

env.workspace = "c:/data/columbia"

# Create a value table that will hold the input feature classes for Merge
vTab = arcpy.ValueTable()

# Step through each dataset in the list
for fd in arcpy.ListDatasets("*", "CAD"):
    layername = fd + "_Layer"
    # Select only the Polyine features on the drawing layer b-railroad
    arcpy.MakeFeatureLayer_management(fd + "/Polyline", layername, "\"Layer\" = 'B-RAILROAD'")

# Merge the CAD features into one feature class
arcpy.Merge_management(vTab, "c:/data/columbia/Columbia.gdb/Railroads")​
0 Kudos