Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I am trying to create a batch file which creates a single script file which i can drop into cad and that script file will open a drawing in a directory (same as batch file) and then load a lisp routine (also in same directory) then run that lisp command, save and close that drawing file and then cycle through each drawing in the same directory and run those same commands.
Below is what i have so far which does what i want it to do however it just endlessly creates the script for only the first drawing from the list instead of going to the next drawing in the list and eventually ending after the list is finished.
@Anonymous off
REM Get the current directory
set script_dir=%~dp0
REM Create the list file
dir /b "%script_dir%*.dwg" > "%script_dir%drawing_list.txt"
REM Create the script file
echo (setq script (open "%script_dir%temp_script.scr" "a")) > "%script_dir%temp_script.scr"
REM Read the first line from the list file
set /p drawing=<"%script_dir%drawing_list.txt"
REM Loop through each drawing in the list file
:loop
if not defined drawing goto :eof
REM Add the commands for the current drawing to the script file
echo (command "_open" "%script_dir%%drawing%") >> "%script_dir%temp_script.scr"
echo (command "_load" "MyProgram.lsp" nil) >> "%script_dir%temp_script.scr"
echo (command "(c:MyCommand)") >> "%script_dir%temp_script.scr"
echo (command "_qsave") >> "%script_dir%temp_script.scr"
echo (command "_close") >> "%script_dir%temp_script.scr"
REM Read the next line from the list file
set /p drawing=<"%script_dir%drawing_list.txt"
REM Continue looping through the drawings
goto :loop
Solved! Go to Solution.