<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: select block with a nested block in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8484246#M95134</link>
    <description>Thanks a lot for your help&lt;BR /&gt;</description>
    <pubDate>Fri, 21 Dec 2018 20:13:25 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-12-21T20:13:25Z</dc:date>
    <item>
      <title>select block with a nested block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8483344#M95123</link>
      <description>&lt;P&gt;Hi all&lt;/P&gt;
&lt;P&gt;i want to select all block with nested block in it call "grille", but idont know how to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;can you help me?&lt;/P&gt;
&lt;P&gt;thank&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 13:48:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8483344#M95123</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-12-21T13:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: select block with a nested block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8483382#M95124</link>
      <description>&lt;DIV style="box-shadow: 8px 8px; font-size: 12px; font-style: italic; color: #336699; margin: 5px 50px 25px 50px; padding: 8px; border: 1px dotted #336699; font-family: verdana;"&gt;Taaz-Ttuj&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;i want to select all block with nested block in it call "grille", but idont know how to do.&lt;/P&gt;
&lt;P&gt;can you help me?&lt;/P&gt;
&lt;/DIV&gt;
&lt;DIV style="font-size: 1.2em; font-family: 'ArtifaktLegendRegular'; line-height: 1.3em; margin: 15px 100px 80px 100px;"&gt;
&lt;P&gt;Take a look at &lt;A href="http://www.theswamp.org/index.php?topic=43053.0" target="_blank"&gt;this thread over at the Swamp&lt;/A&gt;. Post #3 should contain what you need.&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 21 Dec 2018 14:02:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8483382#M95124</guid>
      <dc:creator>rkmcswain</dc:creator>
      <dc:date>2018-12-21T14:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: select block with a nested block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8483467#M95125</link>
      <description>&lt;P&gt;Yes i have see that but that return a list af name or i want to select all block and i don't know haow to transform that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 14:30:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8483467#M95125</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-12-21T14:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: select block with a nested block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8483527#M95126</link>
      <description>&lt;DIV style="font-size: 1.2em; font-family: 'ArtifaktLegendRegular'; line-height: 1.3em; margin: 15px 100px 80px 100px;"&gt;Here is a sample. May not work with dynamic blocks, or blocks nested more than one level deep.&lt;/DIV&gt;
&lt;DIV style="font-size: 1.2em; font-family: 'ArtifaktLegendRegular'; line-height: 1.3em; margin: 15px 100px 80px 100px;"&gt;
&lt;PRE&gt;
(defun c:foo (/ g blst item sset)
  (setq g "")
  (setq blst (_listofblockswithnestedblock "grille"))
  (if blst
    (progn
      (foreach item blst
        (if (eq g "")
          (setq g item)
          (setq g (strcat g "," item))
        )
      )
      (setq sset (ssget "_X" (list '(0 . "INSERT") (cons 2 g))))
      (vl-cmdf "._erase" sset "")
    )
  )
)
&lt;/PRE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 21 Dec 2018 14:58:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8483527#M95126</guid>
      <dc:creator>rkmcswain</dc:creator>
      <dc:date>2018-12-21T14:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: select block with a nested block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8483556#M95127</link>
      <description>&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but for dynamic block can you make it workable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And can you explain me how it work?&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 15:06:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8483556#M95127</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-12-21T15:06:31Z</dc:date>
    </item>
    <item>
      <title>Re: select block with a nested block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8483642#M95128</link>
      <description>&lt;P&gt;@Anonymous&amp;nbsp;hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what do you mean by i want to select a "grille" block with all it's nested blocks?&lt;/P&gt;
&lt;P&gt;and what do you want to do with it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;post a sample dwg&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;moshe&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 15:40:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8483642#M95128</guid>
      <dc:creator>Moshe-A</dc:creator>
      <dc:date>2018-12-21T15:40:21Z</dc:date>
    </item>
    <item>
      <title>Re: select block with a nested block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8483666#M95129</link>
      <description>&lt;P&gt;I have multiple blocks with different name, in&amp;nbsp;some we can find another block nemed "grille".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i want to select only blocks that inclcude "grill"&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 15:45:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8483666#M95129</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-12-21T15:45:56Z</dc:date>
    </item>
    <item>
      <title>Re: select block with a nested block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8483808#M95130</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please could you indicate that you have already posted in others forums !!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://cadxp.com/topic/46321-selection-des-blocs-contenant-un-bloc-indexer/" target="_blank"&gt;http://cadxp.com/topic/46321-selection-des-blocs-contenant-un-bloc-indexer/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can post into multiple forums but please give the Info !&lt;/P&gt;
&lt;P&gt;Because if a solution is found into one forum then we will not spend our time to find a second solution ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;THE HEALTH, Happy Christmas, Thanks, Regards, Patrice&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 16:38:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8483808#M95130</guid>
      <dc:creator>braudpat</dc:creator>
      <dc:date>2018-12-21T16:38:12Z</dc:date>
    </item>
    <item>
      <title>Re: select block with a nested block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8484065#M95131</link>
      <description>&lt;P&gt;@Anonymous,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;here is the command c:test, you can change it to any name you like.&lt;/P&gt;
&lt;P&gt;i know (DatabaseScan) is &lt;SPAN&gt;inefficient&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;but it will work fast as long as your blocks are not so big or very deep.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;look at the first line:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;(setq *BNAME* (strcase "grille,other-block-name"))&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;you can include as much blocks name as you like by delimited their name with "," - ok?&amp;nbsp;&lt;img id="smileylol" class="emoticon emoticon-smileylol" src="https://forums.autodesk.com/i/smilies/16x16_smiley-lol.png" alt="Smiley LOL" title="Smiley LOL" /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;enjoy,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;moshe&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;; Load ActivX Support
(vl-load-com)

;;; database object and containers
(setq *acad-object* nil)      ; Initialize global variable
(defun acad-object ()
  (cond (*acad-object*)       ; Return the cached object
    (t
     (setq *acad-object* (vlax-get-acad-object))
    )
  )
)

(setq *active-document* nil)  ; Initialize global variable
(defun active-document ()
  (cond (*active-document*)   ; Return the cached object
    (t
     (setq *active-document* (vla-get-activedocument (acad-object)))
    )
  )
)


(setq *blocks* nil)      ; Initialize global variable
(defun blocks ()
  (cond (*blocks*)       ; Return the cached object
    (t
     (setq *blocks* (vla-get-blocks (active-document)))
    )
  )
)

(setq *activeSelectionSet* nil)      ; Initialize global variable
(defun activeSelectionSet ()
  (cond (*activeSelectionSet*)       ; Return the cached object
    (t
     (setq *activeSelectionSet* (vla-get-ActiveSelectionSet (active-document)))
    )
  )
)

; select block references according nested 'grille' block name
; support dynamic block
(defun c:test (/ isXRef databaseScan ; local functions
	         *BNAME* ss0 ss1 lst0 lst1 bn bname bnames AcDbEntity)

 (defun isXRef (blk / AcDbBlockTableRecord)
  (and 
   (setq AcDbBlockTableRecord (vla-item (blocks) blk))
   (eq (vla-get-isXRef AcDbBlockTableRecord) :vlax-true)
  )
 ); isXRef
  
 (defun DatabaseScan (bname / flag blk)
  (cond 
   ((wcmatch (strcase bname) *BNAME*)
    (setq flag t)
   )
   ( t
    (vlax-for AcDbEntity (vla-item (blocks) bname) 
     (if (and
          (eq (vla-get-objectName AcDbEntity) "AcDbBlockReference")
          (wcmatch (strcase (setq blk (vla-get-effectivename AcDbEntity))) *BNAME*)
	  (not (isXRef blk)); deny xref
         )
      (setq flag t)
     ); if
      
     (vlax-release-object AcDbEntity)
    ); vlax-for
   ); case
  ); cond

  flag
 ); DatabaseScan

 ; here start command
 (setq *BNAME* (strcase "grille,other-block-name")) 
  
 (if (setq ss0 (ssget '((0 . "insert"))))
  (progn
   (setq lst0 '())
   (vlax-for AcDbEntity (activeSelectionSet)
    (if (not (isXRef (setq bn (vla-get-effectivename AcDbEntity)))) ; deny xref
     (setq lst0 (cons bn lst0))
    )

    (vlax-release-object AcDbEntity)
   ); vlax-for
   
   ; remove duplicate items
   (setq lst1 '())
   (foreach bn lst0
    (if (not (member bn lst1))
     (setq lst1 (cons bn lst1))
    )
   ); foreach

   (setq bnames "")
   (foreach bn lst1
    (if (DatabaseScan bn)
     (setq bnames (strcat bnames bn ","))
    )
   ); foreach
   
   (if (/= bnames "")
    (progn
     (setq bnames (substr bnames 1 (1- (strlen bnames)))) ; remove last ","
     (if (setq ss1 (ssget "x" (list '(0 . "insert") (cons '2 bnames))))
      (sssetfirst ss1 ss1)
      (prompt "\nNoting found.")
     )
    ); progn
   ); if
   
  ); progn
 ); if

 (princ)
); c:test

&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 18:28:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8484065#M95131</guid>
      <dc:creator>Moshe-A</dc:creator>
      <dc:date>2018-12-21T18:28:29Z</dc:date>
    </item>
    <item>
      <title>Re: select block with a nested block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8484184#M95132</link>
      <description>Thank you&lt;BR /&gt;&lt;BR /&gt;It's beautiful, if you have a bit of time can you mark some comments for i&lt;BR /&gt;can understand and learn to do by myself.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I much appreciate your help.  Thanks a lot.&lt;BR /&gt;</description>
      <pubDate>Fri, 21 Dec 2018 19:38:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8484184#M95132</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-12-21T19:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: select block with a nested block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8484227#M95133</link>
      <description>&lt;P&gt;@Anonymous,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;here you are&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;; Load ActivX Support
(vl-load-com)

;;; database object and containers
(setq *acad-object* nil)      ; Initialize global variable
(defun acad-object ()
  (cond (*acad-object*)       ; Return the cached object
    (t
     (setq *acad-object* (vlax-get-acad-object))
    )
  )
)

; return a pointer to active document
(setq *active-document* nil)  ; Initialize global variable
(defun active-document ()
  (cond (*active-document*)   ; Return the cached object
    (t
     (setq *active-document* (vla-get-activedocument (acad-object)))
    )
  )
)

; return a pointer to block records
(setq *blocks* nil)      ; Initialize global variable
(defun blocks ()
  (cond (*blocks*)       ; Return the cached object
    (t
     (setq *blocks* (vla-get-blocks (active-document)))
    )
  )
)

; return a pointer to active selection set
(setq *activeSelectionSet* nil)      ; Initialize global variable
(defun activeSelectionSet ()
  (cond (*activeSelectionSet*)       ; Return the cached object
    (t
     (setq *activeSelectionSet* (vla-get-ActiveSelectionSet (active-document)))
    )
  )
)

; select block references according nested 'grille' block name
; support dynamic block
(defun c:test (/ isXRef databaseScan ; local functions declaration
	         *BNAME* ss0 ss1 lst0 lst1 bn bname bnames AcDbEntity ;| local variables declaration |;)

 ; return T(true) if block is an xref otherwise return nil
 (defun isXRef (blk / AcDbBlockTableRecord)
  (and 
   (setq AcDbBlockTableRecord (vla-item (blocks) blk))
   (eq (vla-get-isXRef AcDbBlockTableRecord) :vlax-true)
  )
 ); isXRef

 ; return T(true) if nested block if found otherwise return nil
 (defun DatabaseScan (bname / flag blk)
  (cond 
   ((wcmatch (strcase bname) *BNAME*)
    (setq flag t) ; header block is match the finding
   )
   ( t
    (vlax-for AcDbEntity (vla-item (blocks) bname) 
     (if (and
          (eq (vla-get-objectName AcDbEntity) "AcDbBlockReference")
          (wcmatch (strcase (setq blk (vla-get-effectivename AcDbEntity))) *BNAME*)
	  ; call local function
	  (not (isXRef blk)); deny xref
         )
      (setq flag t) ; nested block if found
     ); if
      
     (vlax-release-object AcDbEntity) ; dispose object memory
    ); vlax-for
   ); case
  ); cond

  flag ; return
 ); DatabaseScan

 ; here start C:TEST command
 (setq *BNAME* (strcase "grille,other-block-name")) ; set global block names to search
  
 (if (setq ss0 (ssget '((0 . "insert")))) ; pause for user select objects filter only block references (insert)
  (progn
   ; build list of header block names 
   (setq lst0 '()) ; Initialize list
   ; next lines is a loop
   (vlax-for AcDbEntity (activeSelectionSet)
    (if ; call local function
        (not (isXRef (setq bn (vla-get-effectivename AcDbEntity)))) ; deny xref
     (setq lst0 (cons bn lst0))
    )

    (vlax-release-object AcDbEntity) ; dispose object memory
   ); vlax-for
   
   ; remove duplicate items from list lst0 define new list as lst1
   (setq lst1 '()); Initialize list
   ; next lines is a loop
   (foreach bn lst0
    (if (not (member bn lst1))
     (setq lst1 (cons bn lst1))
    )
   ); foreach

   ; construct a list of blocks name as one string delimited by ","
   (setq bnames "") ; Initialize string
   ; next lines is a loop
   (foreach bn lst1
    (if (DatabaseScan bn) ; call local function
     (setq bnames (strcat bnames bn ",")) ; concatinate strings
    )
   ); foreach
   
   (if (/= bnames "") ; is there findings?
    (progn
     (setq bnames (substr bnames 1 (1- (strlen bnames)))) ; remove last ","
     (if (setq ss1 (ssget "x" (list '(0 . "insert") (cons '2 bnames)))) ; excute select objects (no user pause) filter by blocks name in question
      (sssetfirst ss1 ss1)        ; highligh + select blocks on screen
      (prompt "\nNoting found.")  ; send when noting found 
     )
    ); progn
   ); if
   
  ); progn
 ); if

 (princ) ; clean exit to autocad command line window
); c:test

&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Dec 2018 20:04:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8484227#M95133</guid>
      <dc:creator>Moshe-A</dc:creator>
      <dc:date>2018-12-21T20:04:55Z</dc:date>
    </item>
    <item>
      <title>Re: select block with a nested block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8484246#M95134</link>
      <description>Thanks a lot for your help&lt;BR /&gt;</description>
      <pubDate>Fri, 21 Dec 2018 20:13:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8484246#M95134</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-12-21T20:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: select block with a nested block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8484254#M95135</link>
      <description>&lt;P&gt;does it work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please close this thread and mark&amp;nbsp;it as your solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 20:18:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8484254#M95135</guid>
      <dc:creator>Moshe-A</dc:creator>
      <dc:date>2018-12-21T20:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: select block with a nested block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8484990#M95136</link>
      <description>&lt;P&gt;@Anonymous,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After a night sleep&amp;nbsp;i realised that it does not&amp;nbsp;deep search&amp;nbsp;nested blocks plus does not really handle dynamic blocks so here is the fix and hope it will work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;; Load ActivX Support
(vl-load-com)

;;; database object and containers
(setq *acad-object* nil)      ; Initialize global variable
(defun acad-object ()
  (cond (*acad-object*)       ; Return the cached object
    (t
     (setq *acad-object* (vlax-get-acad-object))
    )
  )
)

; return a pointer to active document
(setq *active-document* nil)  ; Initialize global variable
(defun active-document ()
  (cond (*active-document*)   ; Return the cached object
    (t
     (setq *active-document* (vla-get-activedocument (acad-object)))
    )
  )
)


; return a pointer to block records
(setq *blocks* nil)      ; Initialize global variable
(defun blocks ()
  (cond (*blocks*)       ; Return the cached object
    (t
     (setq *blocks* (vla-get-blocks (active-document)))
    )
  )
)

; select block references according nested 'grille' block name
; support dynamic block
(defun c:test (/ isXRef databaseScan is-match ; local functions declaration
	         *BNAME* ss0 ss1 ss2 lst0 lst1 bn blk bname bnames bnames^ AcDbEntity AcDbBlockReference ;| local variables declaration |;)

 ; return T(true) if block is an xref otherwise return nil
 (defun isXRef (blk / AcDbBlockTableRecord)
  (and 
   (setq AcDbBlockTableRecord (vla-item (blocks) blk))
   (eq (vla-get-isXRef AcDbBlockTableRecord) :vlax-true)
   (vlax-release-object AcDbBlockTableRecord) ; dispose memory
  )
 ); isXRef
  
 (defun DatabaseScan (bname / build_list ; local function
		               blk)

  (defun build_list (bn)
   (if (not (member (strcase bn) bnames^))
    (setq bnames^ (cons (strcase bn) bnames^))
   )
  ); build_list

  (build_list bname)
   
  (vlax-for AcDbEntity (vla-item (blocks) bname)
   (if (and
        (eq (vla-get-objectName AcDbEntity) "AcDbBlockReference")
        (setq blk (vla-get-effectivename AcDbEntity))
        ; call local function
        (not (isXRef blk)); deny xref
       )
    (progn
     (build_list blk)
     (DatabaseScan blk) ; recursion call
    ); progn
   ); if

   (vlax-release-object AcDbEntity) ; dispose memory
  ); vlax-for
 ); DatabaseScan
  
 ; return T if match found
 (defun is-match (lst / bn)
  (vl-some
    '(lambda (bn)
      (wcmatch bn *BNAME*) 
     )
   lst
  )
 ); is-applicable
  
 ; here start C:TEST command
 ; const,  ; set global block names to search
 (setq *BNAME* (strcase "grille,other-block-name"))
  
 (if (setq ss0 (ssget '((0 . "insert")))) ; pause for user select objects filter only block references (insert)
  (progn
   ; build list of header block names 
   (setq lst0 '()) ; Initialize list
   ; next lines is a loop
   (vlax-for AcDbEntity (vla-get-ActiveSelectionSet (active-document))
    (if ; call local function
        (not (isXRef (setq bn (vla-get-effectivename AcDbEntity)))) ; deny xref
     (setq lst0 (cons bn lst0))
    )

    (vlax-release-object AcDbEntity) ; dispose object memory
   ); vlax-for
   
   ; remove duplicate items from list lst0 define new list as lst1
   (setq lst1 '()); Initialize list
   ; next lines is a loop
   (foreach bn lst0
    (if (not (member bn lst1))
     (setq lst1 (cons bn lst1))
    )
   ); foreach
   
   ; construct a list of blocks name as one string delimited by ","
   (setq bnames "") ; Initialize string
   ; next lines is a loop
   (foreach bn lst1
    (setq bnames^ '())
    (DatabaseScan bn)
    
    (foreach blk bnames^
     (if (and
	  (is-match bnames^)
          (not (vl-string-search (strcase blk) bnames))
	 )
      (setq bnames (strcat bnames blk ",")) ; concatinate strings
     )
    )
   ); foreach
  
   (if (eq bnames "") ; is there findings?
    (prompt "\nNoting found.")  ; echo noting found 
    (progn
     (setq bnames (substr bnames 1 (1- (strlen bnames)))) ; remove last ","
     ; excute select objects (no user pause) filter by blocks in question
     (if (not (setq ss1 (ssget "x" (list '(0 . "insert") (cons '2 bnames) (cons '410 (getvar "ctab"))))))
      (setq ss1 (ssadd))
     )
      
     ; excute select objects (no user pause) filter by dynamic blocks
     (setq ss2 (ssget "x" (list '(0 . "insert") '(2 . "`*u*") (cons '410 (getvar "ctab")))))
     ; next lines is a loop	   
     (foreach ename (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss2)))	   
      (setq AcDbBlockReference (vlax-ename-&amp;gt;vla-object ename)) ; allocating memory
      (if (vl-string-search (strcase (vla-get-effectivename AcDbBlockReference)) bnames)
       (ssadd ename ss1)
      )

      (vlax-release-object AcDbBlockReference) ; dispose memory
     ); foreach

     (if (&amp;gt; (sslength ss1) 0)
      (sssetfirst ss1 ss1)        ; highligh + select blocks on screen
      (prompt "\nNoting found.")  ; echo noting found 
     )
    ); progn
   ); if
   
  ); progn
 ); if

 (princ) ; clean exit to autocad command line window
); c:test

&lt;/PRE&gt;</description>
      <pubDate>Sat, 22 Dec 2018 17:45:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8484990#M95136</guid>
      <dc:creator>Moshe-A</dc:creator>
      <dc:date>2018-12-22T17:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: select block with a nested block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8485082#M95137</link>
      <description>Thank you so much&lt;BR /&gt;</description>
      <pubDate>Sat, 22 Dec 2018 19:58:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8485082#M95137</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-12-22T19:58:25Z</dc:date>
    </item>
    <item>
      <title>Re: select block with a nested block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8504806#M95138</link>
      <description>&lt;P&gt;Hi&lt;BR /&gt;&lt;BR /&gt;I just saw that you got a solution for your problem.&lt;BR /&gt;I still give the&lt;A href="http://cadxp.com/topic/46321-selection-des-blocs-contenant-un-bloc-specifique/page__view__findpost__p__270281" target="_blank"&gt; link to my solution&lt;/A&gt; because it proposes another way of doing things.&lt;BR /&gt;&lt;BR /&gt;@+&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 14:11:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-block-with-a-nested-block/m-p/8504806#M95138</guid>
      <dc:creator>patrick_35</dc:creator>
      <dc:date>2019-01-07T14:11:15Z</dc:date>
    </item>
  </channel>
</rss>

