Delete all layouts of a batch of DWGs

Delete all layouts of a batch of DWGs

zirudezirude
Advocate Advocate
447 Views
8 Replies
Message 1 of 9

Delete all layouts of a batch of DWGs

zirudezirude
Advocate
Advocate

Hi Gents,

 

I've come across a couple of Lisp routines that delete specific layouts, but I'm looking for a simple Lisp code that can delete all layouts in a batch of drawings without opening them.

 

Thanks in advance for your help, everyone!

0 Likes
448 Views
8 Replies
Replies (8)
Message 2 of 9

paullimapa
Mentor
Mentor

I'm sure you've also found that deleting layouts with accoreconsole would fail so that would mean you have to open the dwgs in order to delete them using lisp....unless you want to try dot net which is at a different forum


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 9

zirudezirude
Advocate
Advocate

thanks @paullimapa for the quick reply.

 

Yes I tried couple of them but comes with error.

so I am looking for a simple lisp that may uses "BrowseForFolderV1-3" through Visual LISP for Autocad console to delete every layout in all dwgs that I want to clean without open them.

0 Likes
Message 4 of 9

paullimapa
Mentor
Mentor

As I mentioned accoreconsole will not work when it comes to deleting or manipulating layouts.

The alternative is to have each file opened and run lisp to delete all layouts.

So you can still use BrowseForFolderV1-3 to select the folder of course but the process will still require the drawings to be opened for the layouts to be deleted.

@zirudezirude 

Here's the simple one line code to delete all layouts (note: layout1 must remain):

(foreach layout (layoutlist) (command "_.layout" "_Del" layout))

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 5 of 9

Sea-Haven
Mentor
Mentor

You must have at least one layout its just one of those things, get the layout list (layoutlst) then make a dummy layout, then erase all the others, in our work dwg's it was rare to have "layout1"

0 Likes
Message 6 of 9

zirudezirude
Advocate
Advocate

Does anyone has a script of that ? please, so I can try it. it will save a lot of time in my work. I do have more than 300 dwg, I was able to find one to purge all of them though. however I need to delete all layouts from all drawings first (without opening them one by one that's take a lot of time and it's not efficient)

I also know that when you delete all layouts from a drawing, Autocad will create a default one and that's fine for our client since it's empty.

 

0 Likes
Message 7 of 9

pendean
Community Legend
Community Legend

@zirudezirude wrote:

Does anyone has a script of that ?...


The tips already given are not working for you? Your script needs to contain the lisp code noted above, here is the direct link

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/delete-all-layouts-of-a-batch-of-dwg...

 

And you need a 3rd party tool to generate a list of DWG file to run that script in each, also discussed above, direct link is below

https://www.lee-mac.com/directorydialog.html

or try this one

https://www.cadig.com/products/autocad-script-pro.php

or this one

https://www.autodesk.com/support/technical/article/caas/tsarticles/ts/7xKPXzhEGzvnF4qzy2Ddi9.html

 

HTH

 

0 Likes
Message 8 of 9

paullimapa
Mentor
Mentor

Adding to @pendean list:

Lee Macs Script Writer

Script Writer | Lee Mac Programming


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 9 of 9

paullimapa
Mentor
Mentor

Try the attached DwgACCPikScrA.lspLayoutDelAll.scr

Save both in a folder specified under Options>Files>Support File Search Path & Trusted Locations:

paullimapa_0-1742411869995.png

Next load the lisp file:

(load"DwgACCPikScrA")

Then run the code by entering at the command prompt:

DwgACCPikScrA

You'll be prompted to select a folder where all the drawings are located.

Then prompted to select the Script file to apply on all these drawings which you'll select LayoutDelAll.scr

Then accoreconsole will launch on each of these dwgs applying that script file to delete all layouts on each dwg in the selected folder.

Again as I've stated before, there's no guarantees layout manipulations will always work with accoreconsole.exe 

But give it a try and hopefully it'll work on most if not all of your dwgs.

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes