Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HOW TO DELETE TITLE BLOCK FROM 2000 FILES ? - Urgent

18 REPLIES 18
Reply
Message 1 of 19
domniq
3117 Views, 18 Replies

HOW TO DELETE TITLE BLOCK FROM 2000 FILES ? - Urgent

Hi,

 

I want to delete title block from 2000 DWG files. How can i achieve this automatically. I need to have a lisp program which runs and process all the dwg files. any help would be greately appreaciated.

 

Thanks

18 REPLIES 18
Message 2 of 19
braudpat
in reply to: domniq

 

Hello

 

Welcome to the Autodesk/AutoCAD Forums !

 

Q1) Your title block is a Block or a Xref ?

 

Q2) Always the SAME Block/Xref name, I presume ?

 

Q3) Is it is inserted in the Model Space ?

 

Q4) Is it inserted in ALL the Layouts or SOME ?

 

For example the following line will select ALL the Block named "TEST" from the CURRENT space :

(ssget "_X" '((0 . "INSERT") (2 . "TEST")))

 

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


Message 3 of 19
braudpat
in reply to: domniq

 

Hello

 

If it's a Block you can use this VLisp routine that I have a little bit simplified

Please remind that I am not a Lisp/Vlisp programmer ... but the routine does the job !

Don't forget to change the block name as you wish !

 

;; 
;; http://forums.augi.com/showthread.php?36146-Remove-Delete-Block-from-multiple-Layouts-at-the-same-ti...
;; Erase A Block from the drawing : Erase into Model Space and into ALL Layouts and then PURGE the drawing 
;;
;; Small modification to erase automatically ONE Block: "TEST"
;; 

;; (defun C:DELETEBLOCK (/ SS BNAME FILTER SSLEN ENT) 
(defun C:DEL_ONE_BLOCK (/ SS BNAME FILTER SSLEN ENT)

;;;;; Change here the name of the block : "TEST" ;;;;; 
  (setq bname "TEST")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  (setq	FILTER (list (cons 0 "INSERT")
		     (cons 2 BNAME)
	       )
	SS     (ssget "_X" FILTER)
  )
  (if SS
    (progn
      (vl-load-com)
      (repeat (setq SSLEN (sslength SS))
	(vlax-invoke-method (vlax-ename->vla-object (ssname ss (setq SSLEN (1- SSLEN)))) 'Delete)
      )
    )
  )
  (command "_purge" "_b" bname "_N")
)

 

I hope it will help you !?

 

Then of course you will have to write a Script (running with FILEDIA = 0) loading all files one by one, then Del_One_Block then, ReSave the drawing and so one ...

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


Message 4 of 19
abubakars
in reply to: domniq

Try with BatchInDatabase tool available to download from Autodesk Exchange App which process the drawings without opening them, so your 2000 + files could be processed much quicker than opening each one for erasing a block

 

1. Load your files into batch tool in 500 nos, it would be easier to manage with small amount rather than adding 2000+ as a single batch and make sure the value in restart batch after no. of file processed is higher or equvalent to the files you prefer to run in each batch, otherwise the batch will restart as the number of files processed the value set for restart.

2. Add command "Block-Delete" with option in model/All Layouts/Selected Layouts

3. Add the command to all files and run the batch

 

Alternatively you can replace the old Title block with another Title block using the command "Block-Replace",

if it is Xref then use command  "Xref-Replace" or "Xref-Detach-Reload-Unload" and then use Xref-Insert" to add new Title block as xref in all layouts.

 

There are plenty of options are there with lots of built-in commands.

 

Let me know if you need more help on this.

 

Message 5 of 19
domniq
in reply to: braudpat

hi thanks for your reply,

 

My title block are few, for example in the attached DWG file i want to keep only the Topo data and delete the rest of the rectangle box and legends.

 

hence i have to remove all the layers and keep only -- SLOPE, TREE_500_SYM, LAMPOST_500_SYM, ROAD_500_LINE, L-_SITEBNRY_E-_Edge.

 

Yes they are from Model Space.

 

Currently i am opening each DWG file and selecting unwanted layer and deleting, but it will take forever to do this task.

 

Hence it wud be greateful if u can suggest a solution to achieve this.

 

Thanks

Message 6 of 19
domniq
in reply to: abubakars

Hi abubakars ,

 

Many thanks for guiding me to this tool.

 

My question,

 

  1. If i want to remove some of the fixed layer can i use this tool ?
  2. Does it also merge multiple dwg files?
  3. Is there any help available for the use of this tool ?

Thanks

 

Message 7 of 19
abubakars
in reply to: domniq

1. You need to erase the entities first which are holding the layers you want to delete and then you can purge those layers

 

Since BtachInDatabase is processing files without opening them the lisp/script commands are not available but you can use another Batch tool "BatchInEditor" where you can add lisp/script commands to do that

 

in BatchInEditor add the commands "Lisp-Expression" and paste the expression as below one by one which deletes the layer and its contents

(command "laydel" "n" "TREE" "" "y")
(command "laydel" "n" "XXXBASE" "" "y") 

 

or you can add the all layers using above syntax which you want to delete them in a separate lisp file and use the command "Lisp-file load" to delete all the layers.

 

2. No it does not merge the drawing files

3. There are demo videos available at http://www.cadmanagertools.com and refer to help file to learn this tool.

 

Message 8 of 19
domniq
in reply to: abubakars

hi abubakar,

 

THANKS a lot, this sounds great. I want to know if this tool need any product key or do we have to purchase any liscense ?

 

Thanks

Message 9 of 19
abubakars
in reply to: domniq

The initial version comes with the limitation of 3 files per session but I reccommend you send the license key request as detailed in the help, which is free as well and no $$$ at all, you can request as many licenses you want.

 

Hope this will help you.

 

Message 10 of 19
domniq
in reply to: abubakars

hi abubakars,

 

The below command (command "laydel" "n" "TREE" "" "y") works well, but it doesnot work when the name of the layer is a numeric value.

like my first layer is "0". Any idea how to use the above commant with the layer name as numeric value ?"

 

it gives me bellow error:

 

Enter layer name or [?]: 0
Cannot delete current layer.
Select object on layer to delete or [Name/Undo]:
Command: y Unknown command "Y".  Press F1 for help.
Command: nil

 

Thanks

Message 11 of 19
braudpat
in reply to: domniq

 

Hello

 

You are speaking about the "0" layer but you can't delete/purge/rename the famous ZERO layer !

 

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


Message 12 of 19
abubakars
in reply to: domniq

Though you can erase the objects in layer "0", it could not be deleted which is the default layer for AutoCAD

but you can delete the layer which starts with numerical values like below lisp expression works.

(command "laydel" "n" "1st Wall" "" "y")
(command "laydel" "n" "3dpoints" "" "y")

 

Regards,

AbubakarS 

Message 13 of 19
domniq
in reply to: abubakars

Hi abubakar,

 

yes i want to delete all the object on the layer 0, which is the current layer. Is there a way i can remove all the objects from this layer. Any command that i can use to remove the objects in this layer ?

 

Thanks

 

Message 14 of 19
domniq
in reply to: braudpat

hi Braudpat ,

 

 

yes i am not able to remove this layer, this layer actually holds a huge  polyline layer which surrounds as a frame for my file, It also has some Text which is not required. Hence I wan to remove the objects of the layer.

 

but below command

 

(command "laydel" "n" "0" "" "y")  says cannot delete current layer.

 

Is there a way to remove all the objects of contents of this layer ?

 

Thanks

Message 15 of 19
braudpat
in reply to: domniq

 

Hello

 

(ssget "_X" '( (8 . "0")))

 

will select ALL objects (on ZERO layer) but ONLY in the current space : the Model Space or the Current Layout

 

If you are in a Layout then TILEMODE = 1 will send you back to the Model Space ...

It could be useful when running a Script file ...

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


Message 16 of 19
abubakars
in reply to: domniq

use the erase command with the piece of code given by pat, like below

(command "erase" (ssget "_X" '( (8 . "0"))) "")

will delete all the entities from Layer "0"

 

Message 17 of 19
domniq
in reply to: abubakars

Thanks both,

 

The commands really worked well. I have succeded in cleaning one file, i will now proceed to run a batch using Batch-In-Database to apply the same ".lsp" file which will process all my data.

 

But i m facing a small challange here after cleaning my layers there are some small portion of legends still appearing on the top of my drawing.

 

The reason these legends are available cause they are the part of the layer i do not wish to delete. However they are the part of the same layer that i wish to keep. But i dont want these legends

 

I just want to delete these small left over legends which lay atop on the empty space.

 

I have to manually select them and delete them, for better understanding i am attaching an image of these pieces. - leftOverLegends.png

 

I am also attaching how my DWG looks after cleaning - CleanButLegendsRemaining.dwg

 

Any help will be appreciated

 

Thanks

Message 18 of 19
M_Hensley
in reply to: domniq

Layer 0 is a special layer that AutoCAD will not allow you to delete. It will always be included in every drawing.

 

Also you cannot delete any layer that is set as current. You can type CLAYER to see what layer is current. Maybe you should set CLAYER to 0 first since it can't be deleted, then any other layer could be deleted without errors.

Message 19 of 19
domniq
in reply to: M_Hensley

Hi,

 

I m facing a small challange here after cleaning my layers there are some small portion of legends still appearing (left over) on the top of my drawing.

 

The reason these legends are available cause they are the part of the layer i do not wish to delete. However I dont want these legends

 

I just want to delete these small left over legends which lay atop on the empty space.

 

I have to manually select them and delete them, for better understanding i am attaching an image of these pieces. - leftOverLegends.png ( i dont want)

 

I am also attaching how my DWG looks after cleaning - CleanButLegendsRemaining.dwg

 

Any help will be appreciated

 

Thanks

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost