38
The following text is a copy of Python script used to convert CAD data into
shapefiles. The Python file can be found on the CD that accompanies this report.
#CAD2SHAPE.py
#This Python script was written to convert the Virginia Base Mapping Project (VBMP)
hydrology tiles from CAD into shapefiles.
#To use, create a new Toolbox in ArcToolbox and add this script to it.
#Open the script in ArcToolbox and following the prompts, choose the workspace
#containing the .DGN files and then choose a different workspace for the output
shapefiles.
#Written by:
# Sara Kidd
# Hampton Roads Planning District Commission
# 723 Woodlake Dr
# Chesapeake, VA 23320
# 757-420-8300
# skidd@hrpdc.org
# April 2005
from win32com.client import Dispatch
import sys
gp = Dispatch("esriGeoprocessing.GpDispatch.1")
gp.SetProduct("ArcInfo")
# Load required toolboxes...
gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management
Tools.tbx")
#Set Workspace
gp.Workspace = sys.argv[1]
OutWorkspace = sys.argv[2]
#Local Variables
seltype = "Polyline"
CAD_Featureclass = "\\Polyline"
CADLayer = "Polyline_Layer"
Filter_Expression = '"Layer" = \'41\''
try:
#Get list of CAD layers
fcs = gp.ListDatasets()
#Reset enumeration so first object is returned
fcs.reset()
A-1