<?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: how to check if object exists? the get entity name in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5451809#M145253</link>
    <description>&lt;P&gt;is there possible to do that with "tblsearch" function ?&lt;/P&gt;&lt;P&gt;(defun c:function ()&lt;/P&gt;&lt;P&gt;(while&lt;/P&gt;&lt;P&gt;(if (tblsearch "block" "block_name")&lt;BR /&gt;;get the entity name&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;)&lt;BR /&gt;)&lt;BR /&gt;(princ)&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;</description>
    <pubDate>Tue, 23 Dec 2014 18:36:55 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2014-12-23T18:36:55Z</dc:date>
    <item>
      <title>how to check if object exists? the get entity name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5451348#M145250</link>
      <description>&lt;P&gt;Lets say i need to put entity name to the database with&amp;nbsp;vlax-ldata-put . How i can check if that object exist and if exist get enitity name ? It need ssget function ?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Dec 2014 09:23:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5451348#M145250</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-12-23T09:23:08Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if object exists? the get entity name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5451396#M145251</link>
      <description>&lt;P&gt;Here is a code i writed&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(defun c:bcount ( / p1 b a n obj name)
 
	(setq p1 (getstring "\Name of Block : "))
	;get the name of the block
 
	(setq b (cons 2 p1))
	;construct a dotted pair - code 2 is for blocks
 
	(setq a (ssget "x" (list b)))
	;filter for the block name
      (progn
     )
	(if (/= a nil)
	;check if there are any blocks of that name
 
	   (progn
	   ;if there is…
 
		(setq n (sslength a))
	    &lt;SPAN&gt;(setq ent (entlast a))&lt;/SPAN&gt;
		;count the number of blocks

		(alert (strcat "\nThere are " (itoa n)  " in the DataBase. Enity: " (itoa ent) ))

	    
		;display the result
 
	   );progn
	   ;if there are no blocks
 
		(alert "\nThere are none in the DataBase")
		;inform the user
 
	);if
 
   (princ)
 
)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;But it dont get entity name in alertbox&lt;/P&gt;</description>
      <pubDate>Tue, 23 Dec 2014 11:21:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5451396#M145251</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-12-23T11:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if object exists? the get entity name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5451469#M145252</link>
      <description>&lt;P&gt;Your code does not appear to have any relationship to your request. &amp;nbsp;Your posted code scans a drawing to find out how many block references you have with a given name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This code is another way to&amp;nbsp;do the same thing as your code body. &amp;nbsp;I am not sure it is any better.&lt;/P&gt;
&lt;PRE&gt;(IF (VL-CATCH-ALL-ERROR-P
      (VL-CATCH-ALL-APPLY
	'(LAMBDA (name)
	   (ALERT
	     (STRCAT "There are "
		     (ITOA (SSLENGTH (SSGET "x" (LIST (CONS 2 name)))))
		     "block references with the name "
		     name
		     ".")))
	(LIST (SETQ name (GETSTRING "\nBlock name: ")))))
  (ALERT
    (STRCAT "There are no block references to the block name "
	    name
	    ".")))&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To answer your OP, if you are storing block names, then the above (or something similar ) could be used to establish whether references exist to a block name. &amp;nbsp;If you want to store the names of entities that are not block references, then use handles. &amp;nbsp;Every object has a handle. &amp;nbsp;Assuming that ename is an entity name.&lt;/P&gt;
&lt;P&gt;(cdr(assoc 5 (entget ename))) returns its handle.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you store a handle, then it is easy to determine the entity still exists.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(handent &amp;lt;handle&amp;gt;) will return nil if the entity doesn't exist. &amp;nbsp;Otherwise it will return the entity's ename.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you store handles, try storing them in a dictionary rather than as ldata.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Dec 2014 13:48:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5451469#M145252</guid>
      <dc:creator>dbroad</dc:creator>
      <dc:date>2014-12-23T13:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if object exists? the get entity name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5451809#M145253</link>
      <description>&lt;P&gt;is there possible to do that with "tblsearch" function ?&lt;/P&gt;&lt;P&gt;(defun c:function ()&lt;/P&gt;&lt;P&gt;(while&lt;/P&gt;&lt;P&gt;(if (tblsearch "block" "block_name")&lt;BR /&gt;;get the entity name&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;)&lt;BR /&gt;)&lt;BR /&gt;(princ)&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;</description>
      <pubDate>Tue, 23 Dec 2014 18:36:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5451809#M145253</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-12-23T18:36:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if object exists? the get entity name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5451880#M145254</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;is there possible to do that with "tblsearch" function ?&lt;/P&gt;
&lt;P&gt;(defun c:function ()&lt;/P&gt;
&lt;P&gt;(while&lt;/P&gt;
&lt;P&gt;(if (tblsearch "block" "block_name")&lt;BR /&gt;;get the entity name&lt;BR /&gt;....&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No.&amp;nbsp; That is about the &lt;EM&gt;definition&lt;/EM&gt; of the Block, which can exist in the drawing even if there are &lt;EM&gt;no&lt;/EM&gt; insertions of it.&amp;nbsp; An entity name is associated with an &lt;EM&gt;insertion&lt;/EM&gt; of it.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Dec 2014 19:43:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5451880#M145254</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2014-12-23T19:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if object exists? the get entity name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5452052#M145255</link>
      <description>&lt;P&gt;then what need to change in this code (below) that it automaticaly get count of specific block (in my case pickets) and entity name? When just pressing &amp;nbsp;function name in command line and all data saving to database with &amp;nbsp;"vlax-ldata-put" ? I searched all forums and didnt find out what more need&lt;/P&gt;&lt;PRE&gt;(IF (VL-CATCH-ALL-ERROR-P
      (VL-CATCH-ALL-APPLY
	'(LAMBDA (name)
	   (ALERT
	     (STRCAT "There are "
		     (ITOA (SSLENGTH (SSGET "x" (LIST (CONS 2 name)))))
		     "block references with the name "
		     name
		     ".")))
	(LIST (SETQ name (GETSTRING "\nBlock name: ")))))
  (ALERT
    (STRCAT "There are no block references to the block name "
	    name
	    ".")))&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Dec 2014 21:58:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5452052#M145255</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-12-23T21:58:43Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if object exists? the get entity name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5452154#M145256</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;then what need to change in this code (below) that it automaticaly get count of specific block (in my case pickets) and entity name? When just pressing &amp;nbsp;function name in command line and all data saving to database with &amp;nbsp;"vlax-ldata-put" ? I searched all forums and didnt find out what more need&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I haven't used (vlax-ldata-put)&amp;nbsp;and am minimally aware of&amp;nbsp;the (...catch...) functions, so someone else may be better able to help with those parts.&amp;nbsp; But a question:&amp;nbsp; What do you mean by getting an entity name when the count of a specific Block&amp;nbsp;can be&amp;nbsp;more than one?&amp;nbsp; Do you want &lt;EM&gt;all&lt;/EM&gt; the entity names [plural]&amp;nbsp;of insertions of that Block?&amp;nbsp; Do you want &lt;EM&gt;any one&lt;/EM&gt; entity name of an insertion of the Block?&amp;nbsp; Do you want a &lt;EM&gt;particular individual&lt;/EM&gt; insertion, such as the first one, or the last one?&amp;nbsp; If you're looking for a &lt;EM&gt;single&lt;/EM&gt; entity name, it is also possible to get the Block &lt;EM&gt;definition&lt;/EM&gt; as an entity name with (tblobjname), but that is unrelated to a count of Block insertions, since it may&amp;nbsp;be present&amp;nbsp;with &lt;EM&gt;no&lt;/EM&gt; insertions, so I don't think that can be what you want.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Dec 2014 00:18:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5452154#M145256</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2014-12-24T00:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if object exists? the get entity name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5452385#M145257</link>
      <description>&lt;P&gt;&lt;EM&gt;Yes, all&lt;/EM&gt;&lt;SPAN&gt; the entity names of insertions of that Block, (for example it should be block named "picket" in my situation) &amp;nbsp;i hope you understood me.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Dec 2014 10:05:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5452385#M145257</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-12-24T10:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if object exists? the get entity name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5452581#M145258</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;&lt;EM&gt;Yes, all&lt;/EM&gt;&lt;SPAN&gt; the &lt;STRONG&gt;entity names&lt;/STRONG&gt; of insertions of that Block, (for example it should be block named "picket" in my situation) &amp;nbsp;i hope you understood me.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not the entity names, but the handles, if you need the enames, &lt;SPAN class="hps"&gt;should be&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;easy for you to&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;modify&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;(vl-load-com)
(defun blk-p (DictName BlkName / ent i lst ss)
  (if (setq ss (ssget "_X" (list '(0 . "INSERT") (cons 2 BlkName))))
    (progn
      (setq lst "")
       (repeat (setq i (sslength ss))
	(setq ent (entget (ssname ss (setq i (1- i))))
	      lst (strcat lst (cdr (assoc 5 ent)) " ")
	)
         )
      (vlax-ldata-put DictName BlkName (vl-string-right-trim " " lst))
      (prompt (strcat "\n " (itoa (sslength ss)) " " BlkName " were added to " DictName " dictionary..."))
      )
    (prompt (strcat "\nNo " BlkName " was found in the dwg..."))
    )
  (princ)
  )
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Usage&lt;/P&gt;
&lt;P&gt;(blk-p "MyDict" "picket")&lt;/P&gt;
&lt;P&gt;"MyDict" = your dictionary name&lt;/P&gt;
&lt;P&gt;"picket" = your block name&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get the data&lt;/P&gt;
&lt;P&gt;(vlax-ldata-get "MyDict" "piked")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hps"&gt;I hope this helps&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hps"&gt;Henrique&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Dec 2014 16:06:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5452581#M145258</guid>
      <dc:creator>hmsilva</dc:creator>
      <dc:date>2014-12-24T16:06:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if object exists? the get entity name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5452907#M145259</link>
      <description>Stupid question how to use this code ? (: just type in command line (blk-p "MyDict" "picket") ? or what ? And why need dictionary name ?</description>
      <pubDate>Thu, 25 Dec 2014 16:45:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5452907#M145259</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-12-25T16:45:01Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if object exists? the get entity name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5452930#M145260</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;...&amp;nbsp;&lt;STRONG&gt;how to use this code&lt;/STRONG&gt; ? (: just type in command line (blk-p "MyDict" "picket") ? or what ? And &lt;STRONG&gt;why need dictionary name&lt;/STRONG&gt; ?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN class="hps"&gt;As&lt;/SPAN&gt;&amp;nbsp; I &lt;SPAN class="hps"&gt;had previously&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;said&lt;/SPAN&gt;, load the code, enter at command line &lt;/P&gt;
&lt;P&gt;(blk-p "MyDict" "picket")&lt;/P&gt;
&lt;P&gt;if there are blocks named "picket" at your dwg, the blocks handles will be stored in a 'dictionary' named MyDict (or &lt;SPAN class="hps alt-edited"&gt;whatever name you&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;prefer&lt;/SPAN&gt;), in a 'key' named 'picket', &lt;SPAN class="hps"&gt;only&lt;/SPAN&gt; &lt;SPAN class="hps alt-edited"&gt;to make it easier&lt;/SPAN&gt; to retrive the ldata with&lt;/P&gt;
&lt;P&gt;(vlax-ldata-get "MyDict" "piked")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you prefer to add ldata to an object, &lt;SPAN class="hps"&gt;instead of&lt;/SPAN&gt; a dictionary, it is also possible.&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hps"&gt;Read about&lt;/SPAN&gt;&amp;nbsp;&lt;A href="http://help.autodesk.com/view/ACD/2015/ENU/?guid=GUID-D2459C22-223C-4C8E-A69C-F288B8FBFA28" target="_blank"&gt;vlax-data-put&lt;/A&gt; and&amp;nbsp;&lt;A href="http://help.autodesk.com/view/ACD/2015/ENU/?guid=GUID-C279216F-9568-4176-A9E7-BCB45E3F59C7" target="_blank"&gt;vlax-ldata-get&lt;/A&gt;&amp;nbsp;&lt;SPAN class="hps"&gt;and should be&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;easy for you to&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;make necessary modifications&lt;/SPAN&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hps"&gt;I hope this helps&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Henrique&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Dec 2014 18:58:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5452930#M145260</guid>
      <dc:creator>hmsilva</dc:creator>
      <dc:date>2014-12-25T18:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if object exists? the get entity name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5453934#M145261</link>
      <description>&lt;P&gt;Thank you very much it works (:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some question about code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(vl-load-com)
(defun blk-p (DictName BlkName / ent i lst ss)
  (if (setq ss (ssget "_X" (list '(0 . "INSERT") (cons 2 BlkName)))) ;in this line it gets x coordinate? and block name?
    (progn
      (setq lst "")
       (repeat (setq i (sslength ss)) 
	(setq ent (entget (ssname ss (setq i (1- i)))) ;what happens here ?
	      lst (strcat lst (cdr (assoc 5 ent)) " ")
	)
         )
      (vlax-ldata-put DictName BlkName (vl-string-right-trim " " lst))
      (prompt (strcat "\n " (itoa (sslength ss)) " " BlkName " were added to " DictName " dictionary..."))
      )
    (prompt (strcat "\nNo " BlkName " was found in the dwg..."))
    )
  (princ)
  )&lt;/PRE&gt;</description>
      <pubDate>Sun, 28 Dec 2014 12:27:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5453934#M145261</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-12-28T12:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if object exists? the get entity name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5453938#M145262</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;Thank you very much it works (:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some question about code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(vl-load-com)
(defun blk-p (DictName BlkName / ent i lst ss)
  (if (setq ss (ssget "_X" (list '(0 . "INSERT") (cons 2 BlkName)))) ;in this line it gets x coordinate? and block name?&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In that line, it filters the selection set to select only the specified block name&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;	(setq ent (entget (ssname ss (setq i (1- i)))) ;what happens here ?
	      lst (strcat lst (cdr (assoc 5 ent)) " ")
	)
         )
      &lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What happens there is, the function &lt;EM&gt;entget &lt;/EM&gt;retrieves the entity data in a form of a list&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;((-1 . &amp;lt;Entity name: 7fffec243f0&amp;gt;)&lt;/P&gt;
&lt;P&gt;(0 . "INSERT")&lt;STRONG&gt;;&amp;lt;---- where this data are store, Entity type&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;(330 . &amp;lt;Entity name: 7ffff732a80&amp;gt;) (5 . "ECFFF") (100 . "AcDbEntity") (67 . 1) (410 . "C-111E")&lt;/P&gt;
&lt;P&gt;(8 . "G-ANNO-SYMB")&lt;STRONG&gt;;&amp;lt;-- &amp;nbsp;Layer Name&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 14px; line-height: 15px;"&gt;(48 . 1.0) (100 . "AcDbBlockReference")&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;(2 . "narrow")&lt;STRONG&gt;&amp;lt;-- Block name&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;(10 213.877 475.369 0.0);&lt;STRONG&gt;&amp;lt;-- insertion point&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;and so on&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTH&lt;/P&gt;</description>
      <pubDate>Sun, 28 Dec 2014 12:44:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5453938#M145262</guid>
      <dc:creator>pbejse</dc:creator>
      <dc:date>2014-12-28T12:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if object exists? the get entity name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5453941#M145263</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;Thank you very much it works (:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You're welcome, 2r33222&lt;BR /&gt;Glad I could help.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;2r33222 wrote:
&lt;P&gt;Some question about code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;2r33222,&lt;/P&gt;
&lt;PRE&gt;(setq ss (ssget "_X" (list '(0 . "INSERT") (cons 2 BlkName)))) ;in this line it gets x coordinate? and block name?
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;ssget = function to create a selection set&lt;/P&gt;
&lt;P&gt;"_X" = the selection set method, X is&amp;nbsp;entire database&lt;/P&gt;
&lt;P&gt;list&amp;nbsp;= to create a list with to filter &lt;SPAN class="hps"&gt;the desired&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;object&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(0 . "INSERT") = associated with the dxf 0 is the object type, an&amp;nbsp; insert&lt;/P&gt;
&lt;P&gt;(cons 2 BlkName) = dxf 2 is the insert name...&lt;/P&gt;
&lt;P&gt;It will create a selectin set with all blocks inseted in the dwg, with the name &lt;SPAN class="hps alt-edited"&gt;we provided&lt;/SPAN&gt;.&lt;/P&gt;
&lt;PRE&gt;	(setq ent (entget (ssname ss (setq i (1- i)))) ;what happens here ?&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN class="hps"&gt;In each&lt;/SPAN&gt; loop it will set the variable i (index) with &lt;SPAN class="hps"&gt;current&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;value&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;subtracted&lt;/SPAN&gt; one (te initial value is the returned from 'sslength ss')&amp;nbsp;, and get &lt;SPAN class="hps"&gt;the entity name&amp;nbsp; from the selection set using the index and the ssname function,&amp;nbsp;then sets &lt;/SPAN&gt;the variable ent with the entity's definition data returned from the entget function...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: &lt;SPAN class="hps alt-edited"&gt;tooooo sloooowwww... &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://forums.autodesk.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hps alt-edited"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pBe &lt;SPAN class="hps"&gt;already&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;explained&lt;/SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hps alt-edited"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Cheers pBe&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hps"&gt;I hope this helps&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hps"&gt;Henrique&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Dec 2014 13:00:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5453941#M145263</guid>
      <dc:creator>hmsilva</dc:creator>
      <dc:date>2014-12-28T13:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if object exists? the get entity name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5453946#M145264</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/75977"&gt;@hmsilva&lt;/a&gt; wrote:&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;EDIT: &lt;SPAN class="hps alt-edited"&gt;tooooo sloooowwww... &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://forums.autodesk.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN class="hps alt-edited"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pBe &lt;SPAN class="hps"&gt;already&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;explained&lt;/SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hps alt-edited"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Cheers pBe&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hps"&gt;I hope this helps&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hps"&gt;Henrique&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I was wondering why the OP would assume the "X" coordinate have anythinbg to do with the selecton&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Well for what its worth, you explained it better than i did&amp;nbsp;&lt;img id="smileyvery-happy" class="emoticon emoticon-smileyvery-happy" src="https://forums.autodesk.com/i/smilies/16x16_smiley-very-happy.png" alt="Smiley Very Happy" title="Smiley Very Happy" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kudos to you my friend &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Dec 2014 13:06:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5453946#M145264</guid>
      <dc:creator>pbejse</dc:creator>
      <dc:date>2014-12-28T13:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if object exists? the get entity name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5453967#M145265</link>
      <description>&lt;HR /&gt;&lt;P&gt;What happens there is, the function &lt;EM&gt;entget &lt;/EM&gt;retrieves the entity data in a form of a list&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;((-1 . &amp;lt;Entity name: 7fffec243f0&amp;gt;)&lt;/P&gt;&lt;P&gt;(0 . "INSERT")&lt;STRONG&gt;;&amp;lt;---- where this data are store, Entity type&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;(330 . &amp;lt;Entity name: 7ffff732a80&amp;gt;) (5 . "ECFFF") (100 . "AcDbEntity") (67 . 1) (410 . "C-111E")&lt;/P&gt;&lt;P&gt;(8 . "G-ANNO-SYMB")&lt;STRONG&gt;;&amp;lt;-- &amp;nbsp;Layer Name&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(48 . 1.0) (100 . "AcDbBlockReference")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;(2 . "narrow")&lt;STRONG&gt;&amp;lt;-- Block name&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;(10 213.877 475.369 0.0);&lt;STRONG&gt;&amp;lt;-- insertion point&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;and so on&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HTH&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So as i understood i can select which data i need ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;by this line :&amp;nbsp;&lt;STRONG&gt;lst (strcat lst (cdr (assoc 5 ent)) " ")&amp;nbsp;&lt;/STRONG&gt;i get ECFF, an entity name i will get with -1 number ?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Dec 2014 13:58:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5453967#M145265</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-12-28T13:58:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if object exists? the get entity name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5453971#M145266</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;&lt;HR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;So as i understood i can select which data i need ?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;by this line :&amp;nbsp;&lt;STRONG&gt;lst (strcat lst (cdr (assoc 5 ent)) " ")&amp;nbsp;&lt;/STRONG&gt;i get ECFF, an entity name i will get with -1 number ?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;That is correct.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;The correct syntax would be. &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;(cdr (assoc 5 ent)) ;&amp;lt;--- it will give you "ECFF" a string value. or are you after somethng else with the strcat function?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good for you&amp;nbsp;&lt;SPAN&gt;2r33222 &lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Dec 2014 14:18:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5453971#M145266</guid>
      <dc:creator>pbejse</dc:creator>
      <dc:date>2014-12-28T14:18:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if object exists? the get entity name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5454003#M145267</link>
      <description>&lt;P&gt;Okay, i read thru the the whole thread and still dont understand exactly want you want to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If we are to base our answers on your OP, IMO dbroad sums it all for you at post #3.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You did ask for&amp;nbsp;&lt;SPAN&gt;vlax-ldata-put, Hmsilva gave you a snippet for that to.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;We're not really sure if you meant Block Name or Handle. What is the purpose of the routine you are wanting to write&amp;nbsp;2r33222? &amp;nbsp;Give us a good description and sample drawings if you may, that way we can give you better suggestions than what we have now.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I'm thinking want you need is a fairly simple code. &amp;nbsp;only thing is, &amp;nbsp;there's a disconnect between every other post you replied to.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Help us help you. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&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>Sun, 28 Dec 2014 15:44:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5454003#M145267</guid>
      <dc:creator>pbejse</dc:creator>
      <dc:date>2014-12-28T15:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if object exists? the get entity name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5454015#M145268</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/564264"&gt;@pbejse&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;What is the purpose of the routine you are wanting to write&amp;nbsp;2r33222? &amp;nbsp;Give us a good description and sample drawings if you may, that way we can give you better suggestions than what we have now.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I'm thinking want you need is a fairly simple code. &amp;nbsp;only thing is, &amp;nbsp;there's a disconnect between every other post you replied to.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Help us help you. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;1+ &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Henrique&lt;/P&gt;</description>
      <pubDate>Sun, 28 Dec 2014 16:03:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5454015#M145268</guid>
      <dc:creator>hmsilva</dc:creator>
      <dc:date>2014-12-28T16:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if object exists? the get entity name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5454328#M145269</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/564264"&gt;@pbejse&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;Okay, i read thru the the whole thread and still dont understand exactly want you want to.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If we are to base our answers on your OP, IMO dbroad sums it all for you at post #3.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You did ask for&amp;nbsp;&lt;SPAN&gt;vlax-ldata-put, Hmsilva gave you a snippet for that to.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;We're not really sure if you meant Block Name or Handle. What is the purpose of the routine you are wanting to write&amp;nbsp;2r33222? &amp;nbsp;Give us a good description and sample drawings if you may, that way we can give you better suggestions than what we have now.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I'm thinking want you need is a fairly simple code. &amp;nbsp;only thing is, &amp;nbsp;there's a disconnect between every other post you replied to.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Help us help you. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&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;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I dont understand exact diferences between handle and block name i quess &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; If there get entity name its fine with that code. I just want to sure&lt;/P&gt;&lt;P&gt;Problem is i am beginner.. Sometimes difficult undertand me because i dont know how to ask.. Sorry for that its hard with me and thank you for your&amp;nbsp;patience (:&lt;/P&gt;</description>
      <pubDate>Mon, 29 Dec 2014 10:05:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-check-if-object-exists-the-get-entity-name/m-p/5454328#M145269</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-12-29T10:05:19Z</dc:date>
    </item>
  </channel>
</rss>

