Jump to content

New to Scripting... Batch script: mapexport to shapefile?


dejesusm42

Recommended Posts

I'm a GIS analyst working with lots of CAD data and I'm looking to make a batch script to iterate thru .dwg's in a folder, apply a predefined export template (think thats an epf file, i can make this), and save the selected features to esri shapefile using the name of the source .dwg as the name of the output shapefile (.shp). I have about 500 files to process, ideally in groups of about 30-50 at a time.

 

I have looked at the "Batch Exporting" Tutorial in AutoCAD Map3D Help, but this only shows how to script and batch mapexport to SDF. I'm looking to tweak the example provided in the tutorial to my requirements but I don't know any of the code words for the other functions/options in the Map 3D Export tool.

 

Any help, pointers, or direction would be appreciated. Thank you.

Link to comment
Share on other sites

1st step write down exactly that all the steps to do 1 dwg export you need to put these into a lisp or script or both. The script will do the open dwg say run a lisp close dwg do next and so on.

 

eg open dwg script and zoom extents then save
open dwg1 zoom e close Y
open dwg2 zoom e close Y

 

; retrive dwg name and path 
(setq dwgname (GETVAR "dwgname"))
(setq dwgloc (getvar "dwgprefix"))
or 
(setq gisname (strcat (getvar "dwgprefix") (getvar "dwgname"))

 

:do a lisp here that exports data and uses gisname for file name 
; maybe mygisexport

 

script
open dwg1 (mygisexport) close N
open dwg2 (mygisexport) close N
open dwg3 (mygisexport) close N

 

Putting them together
appload mygisexport.lsp
script mygisexport.scr
if correct all done !!!

 

Bit more how to make dwg list go to start CMD change to the directory containg your dwgs use CD D:\projects\current etc then type DIR *.dwg >dirlist /b this will make a txt file with a list of your dwgs in it. Then use notepad etc to create the script I use Word has some extra smarts but can bite also when saving. few hundred dwgs say 5 minutes to make script. I know others will suggest a script writer method I just know how to do the old fashoined way.

 

Have ago at export script or lisp first 1 dwg the rest will be easy jusy come back here when it doesn't work.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...