Jump to content

A script to running many scripts


X11start

Recommended Posts

An external software creates me a series of Script files which, once launched, generate a drawing.

I have a folder containing the files:
P01.scr
P02.scr
P03.scr
...

and I would like to run them in sequence, and then save them as single files:
P01.dwg
P02.dwg
P03.dwg
...

I tried with Lee Mac's "ScriptWriter.lsp", but I can't get him to manage Scripts but only DWG.

Does someone have a solution? 
thanks

 
Link to comment
Share on other sites

You have to daisy chain scripts ie last line p01.scr is SCRIPT p02.

 

Should work not tested.

 

I would look more at a lisp solution. Can you describe what your scripts are doing.

Link to comment
Share on other sites

The scripts create a new drawing, starting from the DWT "TQuadro.dwt"; therefore it's not possible to save empty DWGs called P01 - P02 etc.
but the idea of modifying the scripts to recall other "daisy" scripts is interesting!


I found a (very long!) Way, using a DOS batch file:

 

for %% f in (* .scr) do "C: \ Program Files \ Autodesk \ AutoCAD 2019 - Italiano \ acad.exe" / nologo / b %% f

 

(This file called "SCRIPT.BAT")

 

Basically I scroll all the SCR files of the current folder and for each one I open Autocad and execute the script (with the / b option).
/ nologo I use it to speed up opening and not display the Autocad logo.

 

To every file script I must be added:

 

_saveas
    <- This blank line use for ENTER
P01
_quit


This thing can be done manually or with a bat, doing a "COPY >" (to concatenate at the bottom what I need) and FOR ... DO ... etc
but I'm still working on it, because the text P01 obviously has to change with every file.

Concluding:
this is not a "definitive" solution as for each Script it comes:

 

- Open Autocad
- Run the script
- Save file
- Closed Autocad

 

... in short, it takes a lot of time; but you can launch it during your lunch break!

 

I attach the dwg that is created by the script (P01.dwg), the script (P01.scr) and my Batch file (SCRIPT.BAT)

 

Many thanks for your tip!

P01.dwg P01.scr SCRIPT.BAT

Edited by X11start
Link to comment
Share on other sites

You should try using Aeccoreconsole if your going to continue using a BAT file approach works in background no opening of Acad.

 

Nothing to do with you but my latest Win 10 or Norton upgrade has banned opening .scr files so just a comment posters to the forum may have to do "myscript.scr.txt" to get around it. It did actually download Unconfirmed 438070.crdownload

 

Had a quick look at the script if the same for each dwg why not just insert a dwg that has all those items pre saved, save to 0,0 explode once, then -purge Blocks dwgnameinserted or make a new Dwg or DWT.

Edited by BIGAL
Link to comment
Share on other sites

I attached the SCR and the DWG that was obtained, but I did not attach the DWT: it contained the company's data and I did not want to violate the copyright.

Each SCR creates the corresponding DWG starting from the DWT (TQuadro.dwt)

I think the solution is to add instructions to the bottom of each SCR to launch the next SCR (as you suggested in your first post). To do this, if I can't get it with a bat, I'll try to make an exe with QB64.

As soon as I manage to create the EXE, I share it on this post: so it could be useful to others.
Many thanks for all the answers!

 

Link to comment
Share on other sites

Had a look at your dwg so you have a program somewhere that creates the script ? Is it a VBA in excel, could be ported to Autocad, alternatively if excel it can draw in Autocad no need for script.

Link to comment
Share on other sites


The scripts are generated by an external program (perhaps written in VB) which gives us a supplier to calculate the precast panels using their elements. So I can't change it. I can only find the fastest way to turn it into DWG.

Just a tip ... in script file is it possible to use "close" command? I tried putting it after saving the DWG (P01). I running the next script ... (P02) but the script is terminated when it find CLOSE.

 

ex.

 

.... start script

...

...

... end script

_qsave

P01

_close

script

P02

 

The solution would be to not use the "Close" command .... but I can't load 100 or 200 dwg without closing any!
So (if there is no other solution), I believe I will run the scripts in batches of 10.

 

Link to comment
Share on other sites

Do you have any control over the script writing? rather than generate separate scripts can you arrange that the program just creates one large script similar to the following.

filedia
0
circle
0,0
10
saveas

circle.dwg
erase
all

rectangle
0,0
10,10
saveas

rectangle.dwg
erase
all

line
0,0
10,0

saveas

line.dwg
filedia
1
close

This creates the drawing content, saves the file, then deletes everything and creates the next load of drawing content. This way there is no need to keep opening and closing drawings (which as you point out kills the script)

Link to comment
Share on other sites

Not sure had a look at posted script and never had a problem with open close have used this on like 100 dwgs to make slides but it was one script. As suggested if doing a Bat approach use Accorconsole and open each script seperately. Could use a lisp to write the bat file to suit the number of scripts to be processed. Then maybe issue the "shell" command and run the Bat which will run in background.

Link to comment
Share on other sites

It wasn't easy but I found a solution ... in DOS!
I created 2 BAT files to save in the folder that contains the SCR files to be processed.

I preferred try to use BAT files and not use Autolisp .... to be able to do the job also using Autocad LT.

 

START.BAT  (is simple txt file renamed .bat):

 

@echo off

REM
REM  At the end of each file Name File.scr add save command
REM  and renames them aaaNamefile.scr
REM

echo 0 > count.txt

for %%f in (*.scr) do (

  echo FILEDIA 0 _saveas  %%f FILEDIA 1 _quit > count.txt

  type >  aaa%%f %%f count.txt

)


Then the second BAT is launched ...

 

SCRIPT.BAT is ....

 

@echo off

REM
REM  Run autocad for each "aaaNamefile.scr" file in the directory and create the DWG files
REM

for %%f in (aaa*.scr) do "C:\Program Files\Autodesk\AutoCAD LT 2019\acadlt.exe" /nologo /b /six %%f

echo END

 

.... this's how DWGs are created!

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...