Jump to content
Bibix

I'm searching a lisp to select block into block, by name

Recommended Posts

Bibix

hello,

well i'm working on several floor, we got a block made by apartment,

in each apartment, we gad lot of blocks, like exemple "bed",

i'd like to select all the bed in one time to change the layer of this block, i don't want to enter the edit_block to change the layer of the lines, but to have the block "bed" set into the layer "mobilier" as an exemple,

the filter selection by name do not recognize the block into a block, and neither the qselection.

 

i hope someone can helpme,

thanks

 

it's my first post, and i don't speak english very often, so i'm sorry for my errors... :oops:

Share this post


Link to post
Share on other sites
Lee Mac

Assuming I've understood the requirement, here's a quick Vanilla AutoLISP solution for you to try:

(defun c:nestblocklayer ( / blk def ent enx lay )
   (setq blk "bed"      ;; Nested block name
         lay "mobilier" ;; New layer for nested blocks
         blk (strcase blk)
   )
   (while (setq def (tblnext "block" (not def)))
       (setq ent (tblobjname "block" (cdr (assoc 2 def))))
       (while (setq ent (entnext ent))
           (if
               (and
                   (setq enx (entget ent))
                   (= "INSERT" (cdr (assoc 0 enx)))
                   (= blk (strcase (cdr (assoc 2 enx))))
               )
               (entmod (subst (cons 8 lay) (assoc 8 enx) enx))
           )
       )
   )
   (command "_.regenall")
   (princ)
)

Share this post


Link to post
Share on other sites
Bibix

thanks lee for your answer, but it doesen't seems to work,

to be sure i let the lisp file, and the situation i'm needing,

if it was only one block and one layer, i wouldn't use a lisp, but there are several blocks and several files that i need to orgonize well, and there's a lot of appartement :geek::geek:

what i got.dwg

what i need.dwg

lisp lee mac mobilier.lsp

Share this post


Link to post
Share on other sites
Bibix

sorry i tried it friday night i was over, it works perfectly, thk you very much lee,

you're the best!

i'm looking in your web the effective name lisp, so i can select all my dynamic blocs too! i hope, i can select blocs into blocks as well with it!

thanks you very much!

 

Assuming I've understood the requirement, here's a quick Vanilla AutoLISP solution for you to try:
(defun c:nestblocklayer ( / blk def ent enx lay )
   (setq blk "bed"      ;; Nested block name
         lay "mobilier" ;; New layer for nested blocks
         blk (strcase blk)
   )
   (while (setq def (tblnext "block" (not def)))
       (setq ent (tblobjname "block" (cdr (assoc 2 def))))
       (while (setq ent (entnext ent))
           (if
               (and
                   (setq enx (entget ent))
                   (= "INSERT" (cdr (assoc 0 enx)))
                   (= blk (strcase (cdr (assoc 2 enx))))
               )
               (entmod (subst (cons 8 lay) (assoc 8 enx) enx))
           )
       )
   )
   (command "_.regenall")
   (princ)
)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×