Hi All,
I have trialled writing a script and a batch file to carry out a series of tasks to a set of drawings in AutoCAD 2016.
The aim is to open the vendor supplied drawings, add a layer name, switch to a layout, insert a sheet border + attribute sheet, make defpoints the current layer and insert a single viewport, save & close.
Well the script works fine in a single drawing. However when I try to run the batch file, AutoCAD will open the file invoke the script and run as expected, then quit out of AutoCAD, then repeat for the next file, etc, etc.
Is there a way I can speed this up by not shutting down AutoCAD each time. My script trials using 'close' instead of 'quit' do not work, just stops after the first file has been converted.
My Script file (xxxlayer.scr) is as follows;
-Layer
_new
xxx
_m
xxx
-layout
_set
_zoom
_extents
-insert
KCA5-A3E-PCMC.dwg
0,0
1
1
0
_zoom
Extents
-insert
KCA5-A3EA-PCMC.dwg
0,0
1
1
0
-layer
_m
defpoints
_zoom
extents
-vports
20,43
410,287
qsave
quit
My Batch File is as follows;
FOR %%f in (C:\temp\*.dwg) do start /wait C:\"Program Files"\"Autodesk\AutoCAD 2016"\acad.exe "%%f" /b "C:\temp\xxxlayer.scr"
This is something new for me and am relatively pleased with how far I have progressed using information from this forum so far.
Looking forward to continuing to learn
Solved! Go to Solution.
Solved by steven-g. Go to Solution.
Solved by redtransitconsultants. Go to Solution.
My guess is it is in your batch code that is closing CAD each time. I forget what all the switches stand for off hand, but this code seems to work for me, and it does not close CAD after each file.
FOR %%F IN ("C:\MY\FILE\PATH\*.DWG") DO "C:\Program Files\Autodesk\AutoCAD 2016\accoreconsole.exe" /I "%%F" /S "C:\MY\FILE\PATH\MyScript.scr" /L en-US
Steve Hill,Civil Designer / .NET Developer / AutoCAD and AutoCAD Civil 3D Certified Professional
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
http://redtransitconsultants.com/
Autodesk Exchange Store
Twitter | LinkedIn | YouTube
That is just how this method works, the batch file starts autocad and cannot move onto the next file until it receives a signal that Autocad has closed again, if you want to run this script from within an open Autocad session you will be better of learning one of the programming languages within Autocad such as LISP, though I do believe there is a built in method for running a batch file within Autocad (the full version, I use LT so I can't help you on that) try looking at Autocad's scriptpro.
Thanks for the quick response.
I tried the solution a few moments ago and it worked perfectly.
Having seen the benefits of this I think I might now experiment with other script functions.
The next idea I have is to try and use the file name and insert this into an attribute.
Thanks again.
Hello from France,
You can use the SuperAutoScript program from CADERIX
It's very easy to use.
Bye
Yoan AUBRY
Going back to the use of a script in autocad using say Scriptpro, or for me its old fashioned DOS
DIR *.dwg /b >Dirdwg.scr This makes a list of dwg names. I use Word to create the script you can replace the end of para ^p with lines of code so repeating what is required.
I would also make all the commands to be executed to be a lisp. Lisps can be called from scripts so long as no use input required.
so my script would be and Autocad stays open.
Open dwg1 (load "mylisp with all the steps") Close Y Open dwg2 (load "mylisp with all the steps") Close Y Open dwg2 (load "mylisp with all the steps") Close Y
Revisiting this years later...
Can anyone advise how to make Autocad close automatically so that the batch file continues? Currently when I run my batch file (which runs a script performing several basic clean functions, qsave, and then close) it opens a file, performs the script, closes the file but not the program session and the batch file waits until Autocad is fully closed. A user has to manually close the Autocad window so that the batch moves onto the next file. For those who successfully have it automated, what might be incorrect in my batch or perhaps Autocad variable settings?
Here is what I have and know:
Thank you.
Using scripts it was intended to have Autocad open at all times, using a batch file is probably the problem. You can use lisp to make a script file that has the open dwgname line at start.
Look into using accoreconsole it will run in the batch file method.
https://autocadtips1.com/2013/01/30/up-and-running-with-the-2013-core-console/
Can't find what you're looking for? Ask the community or share your knowledge.