layout delete help

layout delete help

pullstackautocad
Enthusiast Enthusiast
226 Views
13 Replies
Message 1 of 14

layout delete help

pullstackautocad
Enthusiast
Enthusiast

I have folder containing 4 ,5 dwg file... i want to delte all layout from the dwg present in the folder....

 

 

Suggest me SUper lazy but powerful method.

0 Likes
227 Views
13 Replies
Replies (13)
Message 2 of 14

BlackBox_
Advisor
Advisor

Write a Script (SCR) and batch process them using Core Console.

 

https://forums.augi.com/showthread.php?172630-Assign-Layer-State-to-Viewport&p=1339054&viewfull=1#po...

 

[Edit] - 

 


 BlackBox wrote:

First take at replacing BSU - C3D team's standalone Batch Save Utility.

Here's the core LISP routine, which uses DOSLib to prompt for multiple drawing + .SCR (script) selection:

** Be sure to replace the text for your profile, file paths, etc as needed **

(vl-load-com)

(defun c:SCRM() (c:ScriptMultiple))
(defun c:ScriptMultiple (/ app flag dwgs dwgPath script cprofile)
;;;
;;;  AcCoreConsole.exe [/i <input dwg>] /s <script>[/product <product>] [/l <language>]
;;;  [/isolate <userid> <userDataFolder>] [/readonly] [/p[rofile] <profile>] 
;;;
  (if
    (and
      (setq app (findfile "accoreconsole.exe"))
      (setq flag (dos_version))
      (setq dwgs
             (dos_getfilem
               "Select drawing(s) to process:"
               (if *Dwg_LastPath*
                 *Dwg_LastPath*
                 (getvar 'dwgprefix)
               )
               "Drawing files (*.dwg)|*.dwg||"
             )
      )
      (setq *Dwg_LastPath* (car dwgs))
      (setq dwgPath *Dwg_LastPath*)
      (setq dwgs (cdr dwgs))
      (setq script
             (dos_getfiled
               "Select a Script to run:"
               (if *Script_LastPath*
                 *Script_LastPath*
                 "C:\\ProgramData\\Autodesk\\C3D 2019\\BatchSaveTool\\Scripts"
               )
               "Script (*.scr)|*.scr||"
             )
      )
      (setq *Script_LastPath* (vl-filename-directory script))
      (setq cprofile (getvar 'cprofile))
    )
     (progn
       (foreach dwg dwgs
         (startapp
           (strcat
             "\""
             app
             "\" /i \""
             dwgPath
             dwg
             "\" /s \""
             script
             "\" /product \"C3D\" /p \"" ; modify for your profile
             cprofile
             "\""
           )
         )
       )
     )
     (cond
       (dwgs (prompt "\n** No script selected ** \n"))
       (flag (prompt "\n** No drawing(s) selected ** \n"))
       (app (prompt "\n** DOSLib required ** \n"))
       ((prompt
          "\n** Unable to find \"AcCoreConsole.exe\" in support paths ** \n"
        )
       )
     )
  )
  (princ)
)

 

Here is a sample .SCR (script) that will reload a given .LAS (layer state):

._-layer
_a
_d
"YourLayerStateName"
_i
"YourFilePath\YourLayerStateFile.las"
_r
"YourLayerStateName"


._regenall
_.qsave
_.close Y
_.quit

 

Cheers



"How we think determines what we do, and what we do determines what we get."

Sincpac C3D ~ Autodesk Exchange Apps

0 Likes
Message 3 of 14

daniel_cadext
Advisor
Advisor

side note augi is not accessible in Singapore, probably blocked on other countries as well  

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
0 Likes
Message 4 of 14

pbejse
Mentor
Mentor

All layout tabs?  why would you want to do that?  is this something you need for a submission requirement?  and you would prefer keep the original intact? 

0 Likes
Message 5 of 14

BlackBox_
Advisor
Advisor

Thanks, @daniel_cadext !

 

What a PITA to convert BB code to HTML.

 

You're in Singapore?! 🍺


"How we think determines what we do, and what we do determines what we get."

Sincpac C3D ~ Autodesk Exchange Apps

0 Likes
Message 6 of 14

daniel_cadext
Advisor
Advisor

Yes, I had a goal to retire on a tropical island, with fresh coconuts, and  good WIFI lol

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
Message 7 of 14

pendean
Community Legend
Community Legend

@pullstackautocad Why not just WBLOCK out all the modelspace content instead?

0 Likes
Message 8 of 14

Sea-Haven
Mentor
Mentor

You still have to have at least one layout in a dwg even if its blank.

 

"The Model tab and the last remaining Layout tab cannot be deleted."

0 Likes
Message 9 of 14

pbejse
Mentor
Mentor

@pendean wrote:

@pullstackautocad Why not just WBLOCK out all the modelspace content instead?


Exactly my point

0 Likes
Message 10 of 14

BlackBox_
Advisor
Advisor

@pbejse wrote:

@pendean wrote:

@pullstackautocad Why not just WBLOCK out all the modelspace content instead?


Exactly my point


So, message #2 stands. Haha


"How we think determines what we do, and what we do determines what we get."

Sincpac C3D ~ Autodesk Exchange Apps

0 Likes
Message 11 of 14

komondormrex
Mentor
Mentor

@pullstackautocad

almost the most lazy method to delete all layouts in every dwg in selected folder, but one.

sdi should be 0.

no dwg of interest should be opened.

(vl-catch-all-apply 'acet-load-expresstools)
(defun c:lazy_del_layouts (/ work_directory document_to_process layout_collection temp_layout)
  (setq work_directory (strcat (acet-ui-pickdir "Pick directory to process" "c:\\") "\\"))
  (foreach dwg_file (vl-directory-files work_directory "*.dwg" 1)
    (princ (strcat "\nDocument \"" (strcat work_directory dwg_file) "\" opened"))
    (setq document_to_process (vla-open (vla-get-documents (vlax-get-acad-object)) (strcat work_directory dwg_file))
          layout_collection (vla-get-layouts (vla-get-database document_to_process))
    )
    (setq temp_layout (vla-add layout_collection "Temp_Layout"))
      (vlax-map-collection layout_collection
      '(lambda (layout)
        (if (/= "Temp_Layout" (vla-get-name layout)) (vl-catch-all-apply 'vla-delete (list layout)))
       )
    )
    (vla-put-name temp_layout "Layout1")
    (vla-save document_to_process)
    (vla-close document_to_process)
    (princ (strcat "\nDocument\"" (strcat work_directory dwg_file) "\" processed and closed\n"))
  )
  (princ)
)
0 Likes
Message 12 of 14

pullstackautocad
Enthusiast
Enthusiast

no problem with the black, but i dont want any of my layout  remanis...

0 Likes
Message 13 of 14

pullstackautocad
Enthusiast
Enthusiast

NO PROMBLE WITH THE BLANK, BUT IT SHOULD DELETE THE OLD.. IS THERE ANY THIRD PARTY APP. OR USING .BAT USING CONSOLE .. FOR ALL THE DWG FILE PRESENT IN THE FOLDER

 

0 Likes
Message 14 of 14

BlackBox_
Advisor
Advisor

@pullstackautocad - if you don't want to use the code in message #2 above, then here's a Script (RightClickDwgWblock.scr): 

(setvar 'ctab "Model")
(command "._-layer" "_u" "*" "")
(setq dwg (strcat (getvar 'dwgprefix) (getvar 'dwgname)))
(setq dwg (strcat (substr dwg 1 (- (strlen dwg) 4)) "_test.dwg"))
(setq overwrite (if (findfile dwg) T))
(if overwrite (command "._-wblock" dwg "_y" "" "_o" "_r" "0,0" "_all" "") (command "._-wblock" dwg "" "_o" "_r" "0,0" "_all" ""))

 

And here's a Windows Shell (aka right click) Menu for File Explorer, so you can simply pick one or more drawings and WBLOCK them at the same time:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\2026RightClickDwgWblock]
@="2026 DWG WBLOCK"
"AppliesTo"=".dwg"
; "Icon"="C:\\Program Files\\Autodesk\\AutoCAD 2026\\accoreconsole.exe"
"HasLUAShield"=""
"Position"="Bottom"

[HKEY_CLASSES_ROOT\*\shell\2026RightClickDwgWblock\command]
@="\"C:\\Program Files\\Autodesk\\AutoCAD 2026\\accoreconsole.exe\" /i \"%1\" /ld \"C:\\Program Files\\Autodesk\\AutoCAD 2026\\AecBase.dbx\" /p \"YourProfileNameHere\" /product \"C3D\" /language \"en-US\" /s \"C:\\YourFilePathHere\\RightClickDwgWblock.scr\""

 

I work in Civil 3D, so change the command's target to match your desktop icon... or just use this Script with the code in message #2 above. 

 

HTH


"How we think determines what we do, and what we do determines what we get."

Sincpac C3D ~ Autodesk Exchange Apps

0 Likes