Code Red > AutoLISP (Vanilla / Visual)

odbx delete entities in a layer

(1/1)

dgpuertas:

I want to use odbx (thanks a lot, lee for this amazing code http://www.lee-mac.com/odbxbase.html)

To delete all entities in a specific layer.

I can't use ssget
How can I do?

Thanks a lot.

Lee Mac:
Iterate over the blocks collection (which includes layouts), and then over the objects within each block (i.e. the objects in every block definition and layout), and use a conditional expression to test whether the object resides on the target layer, deleting if so.

Something like:

--- Code - Auto/Visual Lisp: ---(defun doit ( doc lyr )    (vlax-for blk (vla-get-blocks doc)        (if (= :vlax-false (vla-get-isxref blk))            (vlax-for obj blk                (if (and (= (strcase lyr) (vla-get-layer obj)) (vlax-write-enabled-p obj))                    (vla-delete obj)                )            )        )    )) (LM:odbx '(lambda ( doc ) (doit doc "YourLayer")) nil t)

Navigation

[0] Message Index

Go to full version