+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Forum Newbie
    Discipline
    Architectural
    Using
    AutoCAD 2015
    Join Date
    Nov 2017
    Posts
    4

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

    Registered forum members do not see this ad.

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

  2. #2
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,347

    Default

    Assuming I've understood the requirement, here's a quick Vanilla AutoLISP solution for you to try:
    Code:
    (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)
    )
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  3. #3
    Forum Newbie
    Discipline
    Architectural
    Using
    AutoCAD 2015
    Join Date
    Nov 2017
    Posts
    4

    Default

    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
    Attached Files

  4. #4
    Forum Newbie
    Discipline
    Architectural
    Using
    AutoCAD 2015
    Join Date
    Nov 2017
    Posts
    4

    Default thx, sorry it's work perfectly,

    Registered forum members do not see this ad.

    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!

    Quote Originally Posted by Lee Mac View Post
    Assuming I've understood the requirement, here's a quick Vanilla AutoLISP solution for you to try:
    Code:
    (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)
    )

Similar Threads

  1. LISP Code to Select Block in Layouts and Update Attributes
    By Bill Tillman in forum AutoLISP, Visual LISP & DCL
    Replies: 20
    Last Post: 23rd Sep 2017, 03:45 am
  2. Replies: 0
    Last Post: 26th Jan 2015, 08:08 am
  3. Replies: 3
    Last Post: 23rd Jul 2014, 04:16 am
  4. Need a LISP routine to select lines and copy them to a block
    By gtwatson in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 14th Jul 2011, 02:07 am
  5. Searching for a Block in a drawing
    By bigr1822 in forum AutoLISP, Visual LISP & DCL
    Replies: 10
    Last Post: 22nd Jul 2008, 03:04 pm

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts