Overkill ALL Blocks

Overkill ALL Blocks

jlaidle1
Advocate Advocate
11,854 Views
29 Replies
Message 1 of 30

Overkill ALL Blocks

jlaidle1
Advocate
Advocate

Is there a way with LISP to run the overkill command with all blocks in a drawing?

 

John Laidler
ITO - Application Management


Please use "Accept as Solution" & give "Kudos" if this response helped you.

0 Likes
Accepted solutions (1)
11,855 Views
29 Replies
Replies (29)
Message 21 of 30

dgorsman
Consultant
Consultant

@jlaidle1 wrote:

Excellent point, but our company has 100's of users and most of them do not use best practices.

Also, we get DWG's from suppliers that don't use best practices.  So i'm trying to make an 'easy button' for our users to easily clean up blocks that have overlapping / segmented and duplicate objects.


That is a good point.  However, try to avoid creating "easy buttons" in order to permit users to be sloppy.  Hiding their mistakes might provide good results in the end but doesn't improve their actual abilities.  If they do things at least moderately correctly then you'll only need some occasional fixes/checking which is faster and easier on everyone (including yourself).

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


0 Likes
Message 22 of 30

jotaferrer
Advocate
Advocate

@ВeekeeCZ 

Is there a way, during this command when it's inside a block, to set all object colors by block?

I tried but it keeps "many arguments" alert when try to write in your code. Can you help me, plase?

It would save me...

0 Likes
Message 23 of 30

ВeekeeCZ
Consultant
Consultant

Try to squeeze CHPROP command prior to the overkill.... to both its lines...

 

(command "_.CHPROP" "_all" "" "_C" "BYBLOCK" "" "_.OVERKILL" "_all" "")

 

Message 24 of 30

jotaferrer
Advocate
Advocate

@ВeekeeCZ wrote:

Try to squeeze CHPROP command prior to the overkill.... to both its lines...

 

(command "_.CHPROP" "_all" "" "_C" "BYBLOCK" "" "_.OVERKILL" "_all" "")

 


WOW, you good! Thanks man!

Any chance to merge all layers into a specific one? I've been trying to do this but it's harder than I thought it'd be...

I'd like to either select a layer or or type its name, and after that, everything in the dwg (like ssget "_X") would merge into the layer I've chosen. Do you think you can help me with that task?

 

(vl-load-com)

;;;OVERKILL INNER BLOCKS;;;

(defun c:ovb ( / *error* adoc lst next)

(command "-LAYDEL" "_N" "Hide for GA" "" "_Y")

(defun *error* (errmsg)
(if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
(princ (strcat "\nError: " errmsg)))
(vla-endundomark adoc)
(princ))

(vla-startundomark (setq adoc (vla-get-activedocument (vlax-get-acad-object))))

(vlax-for blk (vla-get-blocks adoc)
(if (and (= 0 (vlax-get blk 'islayout))
(= 0 (vlax-get blk 'isdynamicblock))
(= 0 (vlax-get blk 'isxref))
(vlax-write-enabled-p blk)
(not (wcmatch (vla-get-Name blk) "`*@*"))
)
(setq lst (cons (vla-get-Name blk) lst))))

(foreach n lst
(command "_.-BEDIT" n)
(if (not next)
(command "_.CHPROP" "_all" "" "_C" "BYBLOCK" "" "_.OVERKILL" "_all" "")
(command "_.CHPROP" "_all" "" "_C" "BYBLOCK" "" "_.-OVERKILL" "_all" "" "_Done"))
(command "_.BCLOSE")
(while (> (getvar 'CMDACTIVE) 0)
(command "_save"))
(setq next T))

(if lst (princ (strcat "\n" (itoa (length lst)) " blocks cleaned.")))

(setq ss(ssget "_X"))
(command "_.change" ss "" "_P" "_LA" pause "")
(command "_.audit" "_Y")
(command "-purge" "_R" "" "_N")
(command "-purge" "_A" "" "_N")
(*error* "end")
)
Message 25 of 30

ВeekeeCZ
Consultant
Consultant

You can use this to merge all the objects into one selected layer (0 included). Don't you want to use it prior to the overkill?

 

((lambda ( / e s)
  (if (and (setq e (entsel "Select object to specify a target layer: "))
	   (setvar 'clayer (setq l (cdr (assoc 8 (entget (car e))))))
	   (setq s (ssget "X")))
    (progn
      (repeat (setq i (sslength s))
	(vla-put-layer (vlax-ename->vla-object (ssname s (setq i (1- i)))) l))
      (vlax-for blk (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
	(and (equal (vla-get-islayout blk) :vlax-false)
	     (equal (vla-get-isxref blk) :vlax-false)
	     (vlax-for sub blk (vla-put-layer sub l))))))))

 

Message 26 of 30

jotaferrer
Advocate
Advocate

You're right, I'll put this part before the overkill step. Thanks for the advice


You rock! I'm actually studying your lips to improve my knowledge, very good work and thanks for sharing!

0 Likes
Message 27 of 30

dbrownQTUPQ
Community Visitor
Community Visitor

I'm an advanced AutoCAD user, not programmer, I have a large file that an integrator emailed me with imbedded blocks that can be overkilled individually but wondering if there is a newer way to do this to all the blocks in the drawing?  This is quite a large file around 300mb.  Hundreds of blocks.  I am using AutoCAD 2023.  

 

Thanks!

Damon Brown

Message 28 of 30

S_S_SS
Advocate
Advocate

Hello
I need to make over kill for all blocks with tolerance 10 
I Write this code, but it gives me error 

(command "_.-OVERKILL" (ssget "X" '((0 . "INSERT"))) "" "10" "_Done")

can someone help me to fix this? 
thanks, in advance. 
 

0 Likes
Message 29 of 30

Sea-Haven
Mentor
Mentor

In my -overkill no "10" option ? Is it tolerance etc ?

Message 30 of 30

S_S_SS
Advocate
Advocate

Thanks 

 When i make "10" first it works correctly

Rcact 10 is the tolerance 

(command "_.-OVERKILL" (ssget "X" '((0 . "INSERT"))) "10"  ""  "_Done"

0 Likes