esri to cad script
DESCRIPTION
ESRI to CAD Script. Richard Allen / GIS Public Works City of Richland. 10+ years experience in GIS industry Helped Launch (6) GIS programs Civil Engineer Squadron / RAF Lakenheath Civil Engineer Squadron / Lakeland AFB Joint Command 7 / Bagram Airfield - PowerPoint PPT PresentationTRANSCRIPT
1City of Richland Public Works GISESRI to CAD Script
ESRI to CAD Script
10+ years experience in GIS industry
Helped Launch (6) GIS programs Civil Engineer Squadron / RAF Lakenheath Civil Engineer Squadron / Lakeland AFB Joint Command 7 / Bagram Airfield Air Force Civil Engineer Squadron / Bagram Airfield Civil Engineer Squadron / Fairchild AFB Public Works / City of Richland
ESRI/Python programmer
Richard Allen / GIS Public WorksCity of Richland
2City of Richland Public Works GISESRI to CAD Script
ESRI to CAD ScriptCreate Seed File(s) Create Python
Scripts
Put CAD TogetherRun Script
Create CSV Files
3City of Richland Public Works GISESRI to CAD Script
ESRI to CAD Script
Create Seed file(s) This is how you want your drawing to look Blocks need to be made so that the points have a place to go Linetype names can be saved/stored in the seed file Layers can be saved/stored in either the seed file or the CSV file
• We saved/stored this in the CSV file since our groups wanted different colors Annotation
Blocks Everything else is pretty straight forward except for blocks Depending on how the blocks are created you could have attributes added to them We chose to create two blocks for every feature
• One block shows the feature as well as its attributes when you click on it• The second shows one attribute that can be turned off in the layer manager
Creating Seed Files
4City of Richland Public Works GISESRI to CAD Script
ESRI to CAD ScriptBlock Examples
Final ResultAttribute Only BlockBlock & Hidden Attributes
5City of Richland Public Works GISESRI to CAD Script
ESRI to CAD Script
This ESRI diagram outlines the specific field names that must be used when using the Export to CAD tool
This is the base of everything that was done in this code
CAD Fields DefinedField Calculations
listed below are performed in an
ArcMap Edit session.
CAD Staging
GDB TableField Type
Field Length
CAD Application
(s)Short
Description Effect on Export To CAD
Color Use CAD color numbers Entity Short 2 Both CAD color number A valid value will override the default entity color of the output feature
LineWt Export to AutoCAD, measured in millimeters, maximum value = 9
Setting changes required in AutoCAD to apply this to display
Entity Short 2 AutoCAD Only CAD Line weight value A valid value will control the line weigth of the output feature
Layer Calculate records with suitable values in this field for Layer Names in
the output CAD file.Entity String 255 Both CAD entity layer name A valid value will override the default entity
layer name of the output feature
Handle Entity String 16 Both CAD created entity internal identifier Not Used
RefName If Elevation attribute exists in the data, assign RefName as the Alias for the attribute. The Z-aware output
polylines will store the Z-values. If CadType = "Insert", calculate RefName = the name for the block in the output
AutoCAD file.
Entity String 255 BothCAD entity Block name/
Hatch name /Cell Name/Tag name or Text
Value
A valid value will override the default entity name of the output feature
6City of Richland Public Works GISESRI to CAD Script
ESRI to CAD Script
Edit Python Script The script is designed to run from C:\ Edit _All.py
• Edit what def statements should run Edit the def statements
• Depending on what is needed• The variable CSV file needs to correspond with the actual CSV file
Create New def statements using the one already made Make sure that all def statements are referenced in the _All.py
Edit Python Scripts
7City of Richland Public Works GISESRI to CAD Script
ESRI to CAD Script_All.py Script Example
8City of Richland Public Works GISESRI to CAD Script
ESRI to CAD Script
Edit CSV Files Global.csv
• This is the variable file• inDir_sde, outDir_sde, outDir_fd, inDir_dwg, outDir_dwg
Text – The first three lines are variables• This is the Text file• Name, fc, Layer, sql, LyrColor, Color, TxtFont, LyrFrzn, ProcessIt, Period
Blocks – The first three lines are variables• This is the Blocks file• Name, fc, Layer, sql, LyrColor, Color, Block, Cad Angle, Scale, LyrFrzn, ProcessIt, Period
Lines – The first three lines are variables• This is the Lines file• Name, fc, Layer, sql, LyrColor, Color, Type, LyrFrzn, ProcessIt, Period
Create CSV Files
9City of Richland Public Works GISESRI to CAD Script
ESRI to CAD ScriptCSV Files Examples
var Name fc Layer sql LyrColor Color TxtFont LyrFrzn ProcessIt Period
var inDir_SN
\\PublicWorks.DBO.Irrigation_Network
var rkaSeed_dwg \\Irrigation_Blocks.dwgvar Finished_dwg IrrigationText_base.dwg
dataESRItoDWGirPressurizedMainAnno
PublicWorks.DBO.iwPressurizedMainAnnoPython GIS_IRR TEXT SymbolID = 0 210 256 Existing 0 TRUE 0
dataESRItoDWGirPressurizedMainAnnoAban
PublicWorks.DBO.iwPressurizedMainAnnoPython
GIS_IRR_ABANDON TEXT null 210 256 Existing 0 0
var varName Directoryvar inDir_sde Database Connections\\arcsqlprod01-publicworks.sdevar outDir_sde Database Connections\\arcsqltest01-publicworks.sdevar outDir_fd \\PublicWorks.DBO.Richards_Basevar inDir_dwg C:\\_EsriToDwg\\Files\\Seedvar outDir_dwg C:\\_EsriToDwg\\Files\\Complete\\Base
Irtext.csv
Global.csv
10City of Richland Public Works GISESRI to CAD Script
ESRI to CAD Script
There are a few different ways to run this script Copy the Main script (_All.py) and paste it into ESRI python shell Open with a program like IDLE or PYTHONWIN and run it Double click it to run it.
• There is code in this script to document what happened Schedule it to run in Windows
• Again there is code to document what happened
After the code is finished, review the document to see if anything went wrong If all worked, it is time to put everything together If there were errors, re-run the code with just the parts that did not work
Run Script
11City of Richland Public Works GISESRI to CAD Script
ESRI to CAD Script
Open a blank document and insert drawing When insert do not forget to explode the drawing on insertion After all drawings are inserted wblock the drawing to bring down the file size
A lisp program can be created to do all this in AutoCAD Included on the disc is a lisp program that you can modify
10.1 should make this process easier The program was initially designed to create one drawing per utility There are issues with ESRI’s ExportToCAD tool in 10.0
Put CAD Files Together
12City of Richland Public Works GISESRI to CAD Script
ESRI to CAD Script
If there is any question about this code please let me know
There are (10) CDs that include this code in the back if anyone is interested I will be happy to get the code to anyone that didn’t get a CD
Since this application was created for a public entity, this code is free to share
If you find ways to make the code better or have ideas about it, I would love to hear them
Please feel free to contact me for comments, help or questions Richard Allen (509) 942-7729 [email protected]
Enjoy