Jump to content

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


Bibix

Recommended Posts

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:

Link to comment
Share on other sites

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)
)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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)
)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...