Jump to content

Opening Dwg's one by one in the same application window for executing a script for each of them


Recommended Posts

Posted

I want to run a particular script in AutoCAD on all the files that exist within the directory. For doing that, I have created an executable file  and placed in the directory where all the drawings exist and has the following contents as described in the image.

Capture.thumb.JPG.0240ae590957cdf54a989bd5b8deb1bc.JPG

This script runs perfectly fine, however, the routine opens AutoCAD for one drawing in the directory and closes after running the script, then opens the application again, runs the script, and close and this goes on for every dwg's (200+ in this case). 

 

Does anyone know how to change this routine to open the AutoCAD application just once, for the first drawing and then close the drawing and open another one in the same application?

 

I'm still green in the LISP and any kinda input will be really helpful.

 

TIA!

Cheers,

M

Posted (edited)

Rather than scripting use aeccoreconsole instead of ACAD.exe it is designed to run with out user interaction and does not open dwg, there is examples using the same batch file method as you have.

 

https://through-the-interface.typepad.com/through_the_interface/2012/02/the-autocad-2013-core-console.html
 

https://houseofbim.com/2016/10/05/son-of-a-batch-autocad-core-console-through-lisp/

bat file
echo off

:: Path to AutoCAD core console
set accoreexe="C:\Program Files\Autodesk\AutoCAD 2014\accoreconsole.exe"

:: Path to the script to run
set script="C:\Users\[USERNAME]\Desktop\IPAD\TESTER\tester2.scr"

%accoreexe% /i C:\Users\[USERNAME]\Desktop\IPAD\TESTER\TEST1.dwg /s %script%
%accoreexe% /i C:\Users\[USERNAME]\Desktop\IPAD\TESTER\TEST2.dwg /s %script%
%accoreexe% /i C:\Users\[USERNAME]\Desktop\IPAD\TESTER\TEST3.dwg /s %script%
%accoreexe% /i C:\Users\[USERNAME]\Desktop\IPAD\TESTER\TEST4.dwg /s %script%
%accoreexe% /i C:\Users\[USERNAME]\Desktop\IPAD\TESTER\TEST5.dwg /s %script%
pause

 

 

Edited by BIGAL
  • Like 1
Posted
On 18/07/2020 at 09:54, BIGAL said:

Rather than scripting use aeccoreconsole instead of ACAD.exe it is designed to run with out user interaction and does not open dwg, there is examples using the same batch file method as you have.

 

https://through-the-interface.typepad.com/through_the_interface/2012/02/the-autocad-2013-core-console.html
 


https://houseofbim.com/2016/10/05/son-of-a-batch-autocad-core-console-through-lisp/

bat file
echo off

:: Path to AutoCAD core console
set accoreexe="C:\Program Files\Autodesk\AutoCAD 2014\accoreconsole.exe"

:: Path to the script to run
set script="C:\Users\[USERNAME]\Desktop\IPAD\TESTER\tester2.scr"

%accoreexe% /i C:\Users\[USERNAME]\Desktop\IPAD\TESTER\TEST1.dwg /s %script%
%accoreexe% /i C:\Users\[USERNAME]\Desktop\IPAD\TESTER\TEST2.dwg /s %script%
%accoreexe% /i C:\Users\[USERNAME]\Desktop\IPAD\TESTER\TEST3.dwg /s %script%
%accoreexe% /i C:\Users\[USERNAME]\Desktop\IPAD\TESTER\TEST4.dwg /s %script%
%accoreexe% /i C:\Users\[USERNAME]\Desktop\IPAD\TESTER\TEST5.dwg /s %script%
pause

 

 

This was very helpful BIGAL. The website has a routine to run the script for every file in the directory so all I had to do Is add a stop for the loop and adjust few parameters and it worked. Thanks mate, appreciate it!

Posted
On 17/07/2020 at 23:42, Steven P said:

You might want to look at script processing this - I think Lee Mac has one that could save you a lot of time (http://www.lee-mac.com/scriptwriter.html I think), always worth checking there first

Hi Steven, this was a nice way of performing simple commands over a batch of drawings. However, the only limitation is for adding conditions and handling errors for the script.

Thanks for sharing though!

Posted
14 hours ago, MitS said:

Hi Steven, this was a nice way of performing simple commands over a batch of drawings. However, the only limitation is for adding conditions and handling errors for the script.

Thanks for sharing though!

 

I would suggest using an AutoLISP application to perform the required operations, and using the Script purely to open each drawing, evaluate the AutoLISP program, and then save & close the drawing - I describe this technique here.

  • Like 1

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