<?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: get block name without requiring user to select in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-block-name-without-requiring-user-to-select/m-p/10553258#M56796</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;My current code requires user to select block to get the block name ....&lt;/P&gt;
&lt;P&gt;Is there a way to setq blk using ssget to retrieve the block? ....&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If the goal is to &lt;EM&gt;get&lt;/EM&gt; the Block name, then obviously you can't use &lt;FONT face="arial,helvetica,sans-serif" color="#000000"&gt;(ssget)&lt;/FONT&gt; to find it &lt;EM&gt;by&lt;/EM&gt; its name.&amp;nbsp; So if you don't want to select it by &lt;EM&gt;picking&lt;/EM&gt;, by what criteria would &lt;FONT face="arial,helvetica,sans-serif" color="#000000"&gt;(ssget)&lt;/FONT&gt; look for it?&amp;nbsp; If the Block in question would always be the &lt;EM&gt;last thing drawn&lt;/EM&gt;, you could use that.&amp;nbsp; If it would always have its &lt;EM&gt;insertion point in a specific place&lt;/EM&gt;, you could use that.&amp;nbsp; If it would always be &lt;EM&gt;the &lt;STRONG&gt;only&lt;/STRONG&gt; Block on a specific Layer, or in the current space, or within a specific defined area, or containing Attributes&lt;/EM&gt;, you could use any of those.&amp;nbsp; So what do you know about it that &lt;FONT face="arial,helvetica,sans-serif" color="#000000"&gt;(ssget)&lt;/FONT&gt; can work with to reliably find the one you want and not any other(s)?&lt;/P&gt;</description>
    <pubDate>Tue, 17 Aug 2021 21:48:39 GMT</pubDate>
    <dc:creator>Kent1Cooper</dc:creator>
    <dc:date>2021-08-17T21:48:39Z</dc:date>
    <item>
      <title>get block name without requiring user to select</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-block-name-without-requiring-user-to-select/m-p/10553188#M56794</link>
      <description>&lt;P&gt;My current code requires user to select block to get the block name&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(while 
             (not 
               (and 
                 (setq blk   (car (entsel "\nSelect Block: "))
                       bdata (if blk (entget blk))
                 ) ; end setq
                 (= (cdr (assoc 0 bdata)) "INSERT")
                 (/= 
                   (logand 4 
                           (cdr 
                             (assoc 70 (tblsearch "block" (cdr (assoc 2 bdata))))
                           )
                   )
                   4
                 )
               ) ; end and
             ) ; end not
             (prompt "\nNothing selected, or it is not a Block -- ")
           ) ; end while&lt;/LI-CODE&gt;&lt;P&gt;Is there a way to setq blk using ssget to retrieve the block? for some reason I cant get it to work&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Aug 2021 21:01:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-block-name-without-requiring-user-to-select/m-p/10553188#M56794</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-08-17T21:01:12Z</dc:date>
    </item>
    <item>
      <title>Re: get block name without requiring user to select</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-block-name-without-requiring-user-to-select/m-p/10553229#M56795</link>
      <description>&lt;P&gt;What does the rest of the code do?&lt;/P&gt;</description>
      <pubDate>Tue, 17 Aug 2021 21:31:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-block-name-without-requiring-user-to-select/m-p/10553229#M56795</guid>
      <dc:creator>ronjonp</dc:creator>
      <dc:date>2021-08-17T21:31:04Z</dc:date>
    </item>
    <item>
      <title>Re: get block name without requiring user to select</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-block-name-without-requiring-user-to-select/m-p/10553258#M56796</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;My current code requires user to select block to get the block name ....&lt;/P&gt;
&lt;P&gt;Is there a way to setq blk using ssget to retrieve the block? ....&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If the goal is to &lt;EM&gt;get&lt;/EM&gt; the Block name, then obviously you can't use &lt;FONT face="arial,helvetica,sans-serif" color="#000000"&gt;(ssget)&lt;/FONT&gt; to find it &lt;EM&gt;by&lt;/EM&gt; its name.&amp;nbsp; So if you don't want to select it by &lt;EM&gt;picking&lt;/EM&gt;, by what criteria would &lt;FONT face="arial,helvetica,sans-serif" color="#000000"&gt;(ssget)&lt;/FONT&gt; look for it?&amp;nbsp; If the Block in question would always be the &lt;EM&gt;last thing drawn&lt;/EM&gt;, you could use that.&amp;nbsp; If it would always have its &lt;EM&gt;insertion point in a specific place&lt;/EM&gt;, you could use that.&amp;nbsp; If it would always be &lt;EM&gt;the &lt;STRONG&gt;only&lt;/STRONG&gt; Block on a specific Layer, or in the current space, or within a specific defined area, or containing Attributes&lt;/EM&gt;, you could use any of those.&amp;nbsp; So what do you know about it that &lt;FONT face="arial,helvetica,sans-serif" color="#000000"&gt;(ssget)&lt;/FONT&gt; can work with to reliably find the one you want and not any other(s)?&lt;/P&gt;</description>
      <pubDate>Tue, 17 Aug 2021 21:48:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-block-name-without-requiring-user-to-select/m-p/10553258#M56796</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2021-08-17T21:48:39Z</dc:date>
    </item>
    <item>
      <title>Re: get block name without requiring user to select</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-block-name-without-requiring-user-to-select/m-p/10555019#M56797</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt;&amp;nbsp;&lt;SPAN&gt;If the Block in question would always be the&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;last thing drawn&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;The block/ blocks are copy and pasted into dwg, does this count as last thing drawn? The drawing is simply 1 to 4 blocks that I use my program to turn into rows&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If it would always be&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;only&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Block on a specific Layer&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;All blocks are on same layer, but only need the name of 1. So if rather than ssget "_X" to collect all blocks, I was hoping to use some version of ssget ""_S" and then use bdata to extract name. I can then use that to find the others.&amp;nbsp;&lt;BR /&gt;For some reason, this is not working for me. Using ssget "_X" and then using for loop would also cut down my programming time finding all names at once rather than using tblsearch, but thats not working either.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Aug 2021 13:48:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-block-name-without-requiring-user-to-select/m-p/10555019#M56797</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-08-18T13:48:20Z</dc:date>
    </item>
    <item>
      <title>Re: get block name without requiring user to select</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-block-name-without-requiring-user-to-select/m-p/10555360#M56798</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt;&amp;nbsp;&lt;SPAN&gt;If the Block in question would always be the&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;last thing drawn&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;The block/ blocks are copy and pasted into dwg, does this count as last thing drawn? ....&lt;/P&gt;
&lt;P&gt;....&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If pasting the desired Block in was the last thing done that added anything to the drawn content, then yes, it would be the last thing "drawn."&amp;nbsp; You could do simply:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier" color="#000000"&gt;(setq blk (entlast))&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and go from there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Aug 2021 15:34:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-block-name-without-requiring-user-to-select/m-p/10555360#M56798</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2021-08-18T15:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: get block name without requiring user to select</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-block-name-without-requiring-user-to-select/m-p/10555645#M56799</link>
      <description>&lt;P&gt;If you have 1-4 blocks in a drawing and don't want to pick the block, how do you determine which block needs to be used? Do they all get used?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe this can help you:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;(defun _getnamesofblocksandblocks (/ n r s)
  (vlax-for b (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
    (if	(and (= 0 (vlax-get b 'isxref))
	     (not (wcmatch (setq n (vla-get-name b)) "`**"))
	     (setq s (ssget "_X" (list '(0 . "INSERT") (cons 2 n))))
	)
      (setq r (cons (list n (mapcar 'cadr (ssnamex s))) r))
    )
  )
  r
)
(_getnamesofblocksandblocks)
;; RETURNS '((BLOCKNAME1 (LIST OF BLOCKNAME1 ENAMES))(BLOCKNAME2 (LIST OF BLOCKNAME2 ENAMES)))...&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Aug 2021 17:48:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-block-name-without-requiring-user-to-select/m-p/10555645#M56799</guid>
      <dc:creator>ronjonp</dc:creator>
      <dc:date>2021-08-18T17:48:39Z</dc:date>
    </item>
    <item>
      <title>Re: get block name without requiring user to select</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-block-name-without-requiring-user-to-select/m-p/10556937#M56800</link>
      <description>&lt;P&gt;Maybe add a (cons 410 (getvar 'ctab)) restricts search to say model space or a layout.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If copy paste 4 times I think this works (entlast) look at it get blk name yes / no, erase (entlast), do (entlast) again yes / no save blk name then do a undo B&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;did line circle pline

(command "Undo" "M")
: (entget (entlast))
((-1 . &amp;lt;Entity name: 789a5870&amp;gt;) (0 . "LWPOLYLINE") 
: ERASE
Select entities, edges or faces: (entlast)

: (entget (entlast))
((-1 . &amp;lt;Entity name: 78999ab0&amp;gt;) (0 . "CIRCLE") 
: ERASE
Select entities, edges or faces: (entlast)

: (entget (entlast))
((-1 . &amp;lt;Entity name: 789b8d30&amp;gt;) (0 . "LINE") 

save say ent in lisp
(command "undo" "B")&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 19 Aug 2021 06:11:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-block-name-without-requiring-user-to-select/m-p/10556937#M56800</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2021-08-19T06:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: get block name without requiring user to select</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-block-name-without-requiring-user-to-select/m-p/10557993#M56801</link>
      <description>Your solution is good, but ronjonp's code is a little more specific to what I was looking for</description>
      <pubDate>Thu, 19 Aug 2021 13:32:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-block-name-without-requiring-user-to-select/m-p/10557993#M56801</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-08-19T13:32:09Z</dc:date>
    </item>
  </channel>
</rss>

