CAD discussion forum - ask any CAD-related questions here, share your CAD knowledge on AutoCAD, Inventor, Revit and other Autodesk software with your peers from all over the world. To start a new topic, choose an appropriate forum.
Please abide by the
rules of this forum.
How to post questions: register or login, go to the specific forum and click the NEW TOPIC button.
Author |
Topic Search Topic Options
|
mfkozlow
Groupie
Joined: 14.Jul.2014
Location: United States
Using: AutoCAD Electrical 2014
Status: Offline
Points: 25
|
Topic: Initialize Script Using Batch File Posted: 17.Jul.2014 at 16:59 |
Hello All,
Does anyone know the batch file command to open a set of drawings (several .dwg files) and run a script on each individually using a batch file. I also do not want AutoCAD Electrical to keep closing and opening. I just want one instance of the program. I found this command, but it only works on one drawing at a time.
START \WAIT C:\"Program Files"\Autodesk\"AutoCAD 2014"\ACAD.EXE XXXXX.dwg" /b clean.scr
Here xxxxx.dwg is the drawing file in the same directory as the batch file and clean.scr is the script file in the same directory as the batch file.
I have also tried:
START \WAIT C:\"Program Files"\Autodesk\"AutoCAD 2014"\ACAD.EXE XXXXX.dwg" /b clean.scr xxxxx1.dwg /b clean.scr
The above executes the script on the first drawing, but when it opens the next file (xxxxx1.dwg) it does not run the same script.
Ideally, I want AutoCAD to open one file, run the script, close it without closing AutoCAD. Then I want it to continue onto the next drawing and do the same thing again. Should I approach this problem in the the batch file or have the script open up another file.
NOTE* I do not want to have to input the path of the drawing to open, it should automatically open all the drawings in the directory that the batch file is running in.
Thanks for all your help!
Best Regards, mfkozlow.
|
|
John Connor
Senior Member
Joined: 01.Feb.2011
Location: United States
Using: AutoCAD 2018
Status: Offline
Points: 7175
|
Posted: 17.Jul.2014 at 17:30 |
Maybe this program by Lee Mac might prove more useful.
http://lee-mac.com/scriptwriter.html
|
"Humans have a strength that cannot be measured. This is John Connor. If you are reading this, you are the resistance."
<<AutoCAD 2015>>
|
|
mfkozlow
Groupie
Joined: 14.Jul.2014
Location: United States
Using: AutoCAD Electrical 2014
Status: Offline
Points: 25
|
Posted: 18.Jul.2014 at 17:35 |
Although this is a pretty neat program, I am creating an automated system that requires almost zero user input. That being said, I really need a batch command that opens a .dwg file without opening a new instance of AutoCAD and runs a script located somewhere on the user's computer. Thanks for your fast reply.
|
|
John Connor
Senior Member
Joined: 01.Feb.2011
Location: United States
Using: AutoCAD 2018
Status: Offline
Points: 7175
|
Posted: 18.Jul.2014 at 17:40 |
You must have a system variable that is set wrong if multiple sessions are being opened.
Educate thyself. Read this...
http://forums.autodesk.com/t5/AutoCAD-Electrical-General/sdi-mode/td-p/2705113
Edited by John Connor - 18.Jul.2014 at 17:43
|
"Humans have a strength that cannot be measured. This is John Connor. If you are reading this, you are the resistance."
<<AutoCAD 2015>>
|
|
mfkozlow
Groupie
Joined: 14.Jul.2014
Location: United States
Using: AutoCAD Electrical 2014
Status: Offline
Points: 25
|
Posted: 18.Jul.2014 at 18:01 |
I am aware of this variable. I have it set to 0. The problem is not with AutoCAD, but Windows. I need a way to tell Windows to open the .dwg file with the script, but without having to specify the line below.
START /WAIT C:\"Program Files"\Autodesk\"AutoCAD 2014"\ACAD.EXE
Even if the variable SDI is set to 0, AutoCAD will open as many instances as Windows tells it to. So what I want to do is write the code above and then continue adding drawings into that instance of AutoCAD. The real trick is how do I tell it to run a specific script as each drawing is opened? And more importantly, how do I tell the batch file to wait until that script is finished? Thanks for your support.
|
|
John Connor
Senior Member
Joined: 01.Feb.2011
Location: United States
Using: AutoCAD 2018
Status: Offline
Points: 7175
|
Posted: 18.Jul.2014 at 18:27 |
Why is it a Windows problem? You open AutoCAD first then you run the script not the other way around.
|
"Humans have a strength that cannot be measured. This is John Connor. If you are reading this, you are the resistance."
<<AutoCAD 2015>>
|
|
mfkozlow
Groupie
Joined: 14.Jul.2014
Location: United States
Using: AutoCAD Electrical 2014
Status: Offline
Points: 25
|
Posted: 18.Jul.2014 at 19:20 |
Yes, but I want the script to run automatically, i.e. no user input. I need Windows to tell AutoCAD to open the .dwg file then run the script. Then open another file and run another script, all within one instance of AutoCAD. All I want the user is to double click the batch file and everything will happen automatically from there. Is this making sense or am I not clear in my explanation? Below is a representation:
1. User clicks the batch file. 2. AutoCAD opens. 3. 1st .DWG file is opened and script runs. 4. File closes. 5. 2nd .DWG file opens with a different script. 6. File closes. 7. AutoCAD closes.
Thanks again!
|
|
mfkozlow
Groupie
Joined: 14.Jul.2014
Location: United States
Using: AutoCAD Electrical 2014
Status: Offline
Points: 25
|
Posted: 18.Jul.2014 at 19:58 |
The way I have it setup now is that my batch file (.bat) temporarily creates a script file in the same directory as the batch file. Then once AutoCAD is done using it, the script gets deleted. The problem I have is, how can I open a drawing without starting a new instance of ACAD.EXE? As you can imagine, the time it takes to open AutoCAD can be extensive and doing it twice in a row is completely pointless; especially if these tasks can be done with one instance of AutoCAD. Any suggestions?
|
|
harrissjt
Newbie
Joined: 28.Jan.2015
Location: Australia
Using: Autocad 2012 + Autocad 2015 for Mac
Status: Offline
Points: 10
|
Posted: 28.Jan.2015 at 12:08 |
I have hundreds of Autocad 2012 drawings that I have to modify, each with the same minor changes. The intention is to create Script files to automate each task, and a .BAT file to run the Scripts across multiple files in a given folder. I created a Script file to ZOOM E, and then modify certain attributes within the drawing title block, which appears to work fine when run from within an open Autocad file at the command line. However when trying to run it on multiple files using the .BAT file, it hangs with the following error; "c."ACAD" Invalid file name. Given that the Script runs fine, I assume that there must be an error in my .BAT file. Please see both .BAT file and SCR below; .BAT FOR %%f in (c:\"ACAD Batch"\Drgs\*.dwg) do start /wait c:\"Program Files"\Autodesk\"AutoCAD 2012 - English"\acad.exe "%%f" /b c:\"ACAD Batch"\Scripts\"Change_Project_Title.scr" Script ZOOM E ;EDIT PROJECT REVISION -ATTEDIT N N A*-TITLE REV_NO * A 0 ; ;EDIT PROJECT TITLE-E -ATTEDIT N N A*-TITLE TITLE1 * TA2015 GC-201.1/2/3 CCC POWER SUPPLIES TA2015 GC-201 CCC CONTROLLER UPGRADE ; ;EDIT PROJECT TITLE-R -ATTEDIT N N A*-TITLE TITLE4 * ĐЛЕКТРОПĐТĐĐťĐĐ• НРGC201.1/2/3 CCC КР2015 КР2015 GC-201 МОДЕРН-ЦĐĐŻ КОНТРОЛЛЕРРССС QSAVE QUIT Y I hope that someone out there can help, this has been driving me nuts all day! Cheers, Steve
|
|
John Connor
Senior Member
Joined: 01.Feb.2011
Location: United States
Using: AutoCAD 2018
Status: Offline
Points: 7175
|
Posted: 28.Jan.2015 at 15:53 |
Maybe it has to do with the direction of the slash(es) after C:?
|
"Humans have a strength that cannot be measured. This is John Connor. If you are reading this, you are the resistance."
<<AutoCAD 2015>>
|
|