Batch processing multiple groups of *.shp files in autoCAD Maps 3D 2021

165 Views Asked by At

I am new to batch files and AutoCAD scripts, so at this point I'm curious about if my proposed path makes sense, or if there is a much better way to do it.

Basically I have a set of *.shp files in this structure:

*Parent\SiteA\SiteA.shp
*Parent\SiteA\Shape1.shp
*Parent\SiteA\Shape2.shp
*Parent\SiteB\SiteB.shp
*Parent\SiteB\Shape1.shp
*Parent\SiteB\Shape2.shp

...etc, for hundreds of sites. What I want to do is open a drawing, load all the *.shp files from a site folder, save the drawing as a *.dwg, close the drawing, and move to the next site folder.

I am not terribly concerned about the speed, so I am currently thinking something like this:

  1. Batch file in Parent hunts for Site#.shp
  2. When Site#.shp is found, batch file opens AutoCAD Maps to a blank *.dwg and executes a script
  3. The script is a -MAPIMPORT list that opens Site#.shp and any other Shape1.shp or Shape2.shp files (Shape#.shp are all known names, Site#.shp changes).
  4. Once the imports are done, the *.dwg is saved in the Site# folder.
  5. AutoCAD closes (optional)
  6. The batch file seeks out the next Site#.shp file, repeats.

Something like this lets me find all the Site#.shp files in the respective subdir:

FOR /f %%i IN ('dir /b /s "c:\Parent\Site*.shp"') DO echo %%i >> list.txt

but I'm not sure how easy it will be to identify the Site# once in ACAD in my script. Perhaps something with the file path?

I am not running this nightly or anything, so if it makes more sense to run this from within an opened instance of ACAD Maps I can certainly do that, simplifying steps 2 and 5 maybe. Or, if there are better ways to approach this I am very interested.

0

There are 0 best solutions below