120 likes | 248 Views
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
E N D
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 • Air Force Civil Engineer Squadron / Bagram Airfield • Civil Engineer Squadron / Fairchild AFB • Public Works / City of Richland • ESRI/Python programmer City of Richland Public Works GIS ESRI to CAD Script
ESRI to CAD Script • Create Python Scripts Create Seed File(s) • Create CSV Files • Put CAD Together • Run Script City of Richland Public Works GIS ESRI to CAD Script
ESRI to CAD Script Creating Seed Files • 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 City of Richland Public Works GIS ESRI to CAD Script
ESRI to CAD Script Block Examples Attribute Only Block Final Result Block & Hidden Attributes City of Richland Public Works GIS ESRI to CAD Script
ESRI to CAD Script CAD Fields Defined • 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 City of Richland Public Works GIS ESRI to CAD Script
ESRI to CAD Script Edit Python Scripts • 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 fileneeds 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 City of Richland Public Works GIS ESRI to CAD Script
ESRI to CAD Script _All.py Script Example City of Richland Public Works GIS ESRI to CAD Script
ESRI to CAD Script Create CSV Files • 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 City of Richland Public Works GIS ESRI to CAD Script
ESRI to CAD Script CSV Files Examples Global.csv Irtext.csv City of Richland Public Works GIS ESRI to CAD Script
ESRI to CAD Script Run 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 City of Richland Public Works GIS ESRI to CAD Script
ESRI to CAD Script Put CAD Files Together • 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 ExportToCADtool in 10.0 City of Richland Public Works GIS ESRI to CAD Script
ESRI to CAD Script Enjoy • 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 • rallen@ci.richland.wa.us City of Richland Public Works GIS ESRI to CAD Script