<?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: Help with entsel in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8567018#M93340</link>
    <description>&lt;P&gt;I tried what you sent and I get error:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;bad argument type: lselsetp nil&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Any ideas?&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 01 Feb 2019 16:17:00 GMT</pubDate>
    <dc:creator>DC-MWA</dc:creator>
    <dc:date>2019-02-01T16:17:00Z</dc:date>
    <item>
      <title>Help with entsel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8565775#M93334</link>
      <description>&lt;P&gt;Hi again,&lt;/P&gt;
&lt;P&gt;I have my sub routine working and now i want to add to my insert routine.&lt;/P&gt;
&lt;P&gt;This line:&lt;/P&gt;
&lt;P&gt;(setq bnm (cdr (assoc 2 (entget (car (entsel "\nSelect Detail Tag Block: ")))))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;needs to access the last block inserted. I've tried entlast but it feeds different information.&lt;/P&gt;
&lt;P&gt;See attached code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Feb 2019 05:07:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8565775#M93334</guid>
      <dc:creator>DC-MWA</dc:creator>
      <dc:date>2019-02-01T05:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: Help with entsel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8565827#M93335</link>
      <description>&lt;P&gt;I've merely inserted one line instead of your (entsel) version, and it's untested, but I suppose that it do what you asked for...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;;creates hyperlink to drawing and view based on attribute values of detail block.
;
(defun c:test4 ( / cmde bnm blks i ent DETAILNO SHEETNO HYPERPATH )
  (setq cmde (getvar 'cmdecho))
  (setvar "cmdecho" 0)
  (setq bnm (cdr (assoc 2 (entget (car (mapcar 'cadr (ssnamex (ssget "_X" '((0 . "INSERT"))))))))))
  ;(setq bnm (cdr (assoc 2 (entget (car (entsel "\nSelect Detail Tag Block: "))))));;;select last block inserted instead?;look in previous line ^^
  (setq blks (ssget "_X" (list (cons 2 bnm) '(66 . 1))))
  (repeat (setq i (sslength blks))
    (setq ent (ssname blks (setq i (1- i))))
    (setq DETAILNO (getpropertyvalue ent "XX"))
    (setq SHEETNO (getpropertyvalue ent "XXXX"))
    (setq HYPERPATH (strcat SHEETNO " - ARCHITECTURAL DETAILS.dwg#" DETAILNO))
    (command "detachurl" ent "")
    (command "-hyperlink" "insert" "object" ent "" HYPERPATH "" "")
  );end repeat
  (prompt "\n....\nCreating Hyperlink to detail drawing...")
  (princ (strcat "\nLink to detail #" DETAILNO " on sheet " SHEETNO " complete."))
  (setvar "cmdecho" cmde)
  (princ)
)&lt;/PRE&gt;
&lt;P&gt;Regards...&lt;/P&gt;</description>
      <pubDate>Fri, 01 Feb 2019 06:19:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8565827#M93335</guid>
      <dc:creator>marko_ribar</dc:creator>
      <dc:date>2019-02-01T06:19:15Z</dc:date>
    </item>
    <item>
      <title>Re: Help with entsel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8565861#M93336</link>
      <description>&lt;P&gt;If you only want the block name of the last inserted block, you can leave the MAPCAR out I guess.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(setq bnm (cdr (assoc 2 (entget (cadr (car (ssnamex (ssget "_X" '((0 . "INSERT"))))))))))&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Feb 2019 06:45:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8565861#M93336</guid>
      <dc:creator>DannyNL</dc:creator>
      <dc:date>2019-02-01T06:45:55Z</dc:date>
    </item>
    <item>
      <title>Re: Help with entsel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8565983#M93337</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6400150"&gt;@DC-MWA&lt;/a&gt;&amp;nbsp;hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i see you are very active lately and you are learning a lot and we all very happy to see that - so keep up the good work&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;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;above the good help you got from&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/940934"&gt;@marko_ribar&lt;/a&gt;&amp;nbsp; and&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3144455"&gt;@DannyNL&lt;/a&gt;&amp;nbsp; i have one remark:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where user interaction involves e.g pausing to get some input, better to bring in&amp;nbsp;consideration that wrong\unexpected value will enter plus this is the spot where the user will also want to exit (or escape)&lt;/P&gt;
&lt;P&gt;good programming code must take care of these situations - agree?!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so when using (entsel) or (getXXXX) functions first check the value entered and only if it's positive value you expected continue your program otherwise you end up with autolisp error (not nice).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;for example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(if (and
 &amp;nbsp; &amp;nbsp; &amp;nbsp;(setq pick (entsel "\nSelect block: "))
 &amp;nbsp; &amp;nbsp; &amp;nbsp;(setq elist (entget (car pick)))			; get entity database
 &amp;nbsp; &amp;nbsp; &amp;nbsp;(eq (strcase (cdr (assoc 0 elist))) "INSERT")	; verifies it's a block
 &amp;nbsp; &amp;nbsp; &amp;nbsp;(eq (strcase (cdr (assoc 2 elist))) "BLOCKNAME")	; verifies it's name
 &amp;nbsp; &amp;nbsp; &amp;nbsp;(= (cdr (assoc 66 elist)) 1)			; has attributes?
 &amp;nbsp; &amp;nbsp;)
&amp;nbsp;(progn
  ; continue your code
  ; ...
  ; ..
  ; .
&amp;nbsp;); progn
); if
&lt;/PRE&gt;
&lt;P&gt;as you can see if the user want's to exist he can just press enter (or even in this case pick on empty point)&lt;/P&gt;
&lt;P&gt;if the entity selected is not an attribute block with the expected name the program is quiet exit&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;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;enjoy&lt;/P&gt;
&lt;P&gt;moshe&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>Fri, 01 Feb 2019 08:12:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8565983#M93337</guid>
      <dc:creator>Moshe-A</dc:creator>
      <dc:date>2019-02-01T08:12:34Z</dc:date>
    </item>
    <item>
      <title>Re: Help with entsel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8566893#M93338</link>
      <description>&lt;P&gt;Thank you Moshe. I always learn and value your input.&lt;/P&gt;
&lt;P&gt;Your patience and wisdom are much appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Feb 2019 15:30:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8566893#M93338</guid>
      <dc:creator>DC-MWA</dc:creator>
      <dc:date>2019-02-01T15:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: Help with entsel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8566914#M93339</link>
      <description>&lt;P&gt;I tried both the versions you sent.&lt;/P&gt;
&lt;P&gt;I get error:&lt;/P&gt;
&lt;P&gt;bad argument type: lselsetp nil&lt;/P&gt;</description>
      <pubDate>Fri, 01 Feb 2019 15:37:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8566914#M93339</guid>
      <dc:creator>DC-MWA</dc:creator>
      <dc:date>2019-02-01T15:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: Help with entsel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8567018#M93340</link>
      <description>&lt;P&gt;I tried what you sent and I get error:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;bad argument type: lselsetp nil&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Any ideas?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Feb 2019 16:17:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8567018#M93340</guid>
      <dc:creator>DC-MWA</dc:creator>
      <dc:date>2019-02-01T16:17:00Z</dc:date>
    </item>
    <item>
      <title>Re: Help with entsel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8567021#M93341</link>
      <description>&lt;P&gt;Are you sure your &lt;FONT color="#FF0000"&gt;last inserted block is attributed block&lt;/FONT&gt; with property parameters you are expecting to obtain and use later in hyperlinking corresponding references matching its name? Your drawing either don't have blocks inserted or there are no matching &lt;FONT color="#FF0000"&gt;attributed&lt;/FONT&gt; references so that your last insertion block is without attributes in its main definition. That is an error you received... When you fix your drawing situation, you may encounter next error also depending of current drawing situation and weather your blocks have properties you hard coded as "XX" and "XXX" from which you want to obtain values for later hyperlinking... Next your blocks may not already have assigned hyperlinks so that perhaps line with "detachurl" is surplus and maybe not needed - you should consider checking for hyperlink data assignments prior to hard coding step for detaching url...&lt;/P&gt;</description>
      <pubDate>Fri, 01 Feb 2019 16:17:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8567021#M93341</guid>
      <dc:creator>marko_ribar</dc:creator>
      <dc:date>2019-02-01T16:17:15Z</dc:date>
    </item>
    <item>
      <title>Re: Help with entsel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8567028#M93342</link>
      <description>&lt;P&gt;See attached drawing with detail block inserted.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Feb 2019 16:21:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8567028#M93342</guid>
      <dc:creator>DC-MWA</dc:creator>
      <dc:date>2019-02-01T16:21:28Z</dc:date>
    </item>
    <item>
      <title>Re: Help with entsel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8567086#M93343</link>
      <description>&lt;P&gt;Like I said, that block in Model Space isn't your last inserted block in complete CAD database - there are blocks in other Layouts... So consider this quick fix, but you should also read my previous advice and debug your code further more until its all correct...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;;creates hyperlink to drawing and view based on attribute values of detail block.
;
(defun c:test4 ( / cmde bnm blks i ent DETAILNO SHEETNO HYPERPATH )
  (setq cmde (getvar 'cmdecho))
  (setvar "cmdecho" 0)
  (setq bnm (cdr (assoc 2 (entget (car (mapcar 'cadr (ssnamex (ssget "_X" '((0 . "INSERT") &lt;FONT color="#FF0000"&gt;(410 . "Model")&lt;/FONT&gt;)))))))))
  ;(setq bnm (cdr (assoc 2 (entget (car (entsel "\nSelect Detail Tag Block: "))))));;;select last block inserted instead?;look in previous line ^^
  (setq blks (ssget "_X" (list (cons 2 bnm) '(66 . 1))))
  (repeat (setq i (sslength blks))
    (setq ent (ssname blks (setq i (1- i))))
    (setq DETAILNO (getpropertyvalue ent "XX"))
    (setq SHEETNO (getpropertyvalue ent "XXXX"))
    (setq HYPERPATH (strcat SHEETNO " - ARCHITECTURAL DETAILS.dwg#" DETAILNO))
    (command "detachurl" ent "")
    (command "-hyperlink" "insert" "object" ent "" HYPERPATH "" "")
  );end repeat
  (prompt "\n....\nCreating Hyperlink to detail drawing...")
  (princ (strcat "\nLink to detail #" DETAILNO " on sheet " SHEETNO " complete."))
  (setvar "cmdecho" cmde)
  (princ)
)&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Feb 2019 16:42:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8567086#M93343</guid>
      <dc:creator>marko_ribar</dc:creator>
      <dc:date>2019-02-01T16:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: Help with entsel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8567242#M93344</link>
      <description>&lt;P&gt;I'm confused. If I insert the block and know it's the operation performed. Is it not the last item in drawing? If I enter move "last" it selects the block in question?&lt;/P&gt;
&lt;P&gt;Please advise.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The quick fix seems to work though.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Feb 2019 17:32:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8567242#M93344</guid>
      <dc:creator>DC-MWA</dc:creator>
      <dc:date>2019-02-01T17:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: Help with entsel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8567264#M93345</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6400150"&gt;@DC-MWA&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm confused. If I insert the block and know it's the operation performed. Is it not the last item in drawing? If I enter move "last" it selects the block in question?&lt;/P&gt;
&lt;P&gt;Please advise.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The quick fix seems to work though.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, it's not last entity in database - Model Space is first and then follows Layouts in order they appear in Layout Tab...&lt;/P&gt;
&lt;P&gt;That was though quick fix... I recommend better one - checking your currently active space :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;;creates hyperlink to drawing and view based on attribute values of detail block.
;
(defun c:test4 ( / cmde bnm blks i ent DETAILNO SHEETNO HYPERPATH )
  (setq cmde (getvar 'cmdecho))
  (setvar "cmdecho" 0)
  (setq bnm (cdr (assoc 2 (entget (car (mapcar 'cadr (ssnamex (ssget "_X" (list '(0 . "INSERT") &lt;FONT color="#FF0000"&gt;(cons 410 (getvar 'ctab))&lt;/FONT&gt;)))))))))
  ;(setq bnm (cdr (assoc 2 (entget (car (entsel "\nSelect Detail Tag Block: "))))));;;select last block inserted instead?;look in previous line ^^
  (setq blks (ssget "_X" (list (cons 2 bnm) '(66 . 1))))
  (repeat (setq i (sslength blks))
    (setq ent (ssname blks (setq i (1- i))))
    (setq DETAILNO (getpropertyvalue ent "XX"))
    (setq SHEETNO (getpropertyvalue ent "XXXX"))
    (setq HYPERPATH (strcat SHEETNO " - ARCHITECTURAL DETAILS.dwg#" DETAILNO))
    (command "detachurl" ent "")
    (command "-hyperlink" "insert" "object" ent "" HYPERPATH "" "")
  );end repeat
  (prompt "\n....\nCreating Hyperlink to detail drawing...")
  (princ (strcat "\nLink to detail #" DETAILNO " on sheet " SHEETNO " complete."))
  (setvar "cmdecho" cmde)
  (princ)
)&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Feb 2019 17:38:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8567264#M93345</guid>
      <dc:creator>marko_ribar</dc:creator>
      <dc:date>2019-02-01T17:38:08Z</dc:date>
    </item>
    <item>
      <title>Re: Help with entsel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8567285#M93346</link>
      <description>&lt;P&gt;When possible use a function ( vla-insertblock ) that will return an object rather than relying on (entlast). Then you know for sure you have the correct object.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is not necessary to convert the pickset to a list since you're only interested in the first item:&lt;/P&gt;
&lt;PRE&gt;(setq bn (cond ((setq s (ssget "_X" (list '(0 . "INSERT") (cons 410 (getvar 'ctab)))))
		(cdr (assoc 2 (entget (ssname s 0))))
	       )
	 )
)&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Feb 2019 17:49:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8567285#M93346</guid>
      <dc:creator>ronjonp</dc:creator>
      <dc:date>2019-02-01T17:49:54Z</dc:date>
    </item>
    <item>
      <title>Re: Help with entsel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8567321#M93347</link>
      <description>&lt;P&gt;You are right &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/593837"&gt;@ronjonp&lt;/a&gt; ... BTW. I've checked - no errors if (command "_.detachurl" ent "") is applied and previously no urls attached... So everything should work IMHO as it is posted, though I'd avoid using (getpropertyvalue) function as prior A2012 those weren't implemented ((getpropertyvalue) (setpropertyvalue) (dumpallproperties))... Instead I'd iterate through block reference definition and find those attributes from which I'd pull out values...&lt;/P&gt;</description>
      <pubDate>Fri, 01 Feb 2019 17:58:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8567321#M93347</guid>
      <dc:creator>marko_ribar</dc:creator>
      <dc:date>2019-02-01T17:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: Help with entsel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8567352#M93348</link>
      <description>&lt;P&gt;Thanks for the valued input and assistance.&lt;/P&gt;
&lt;P&gt;As far as command not working in previous versions....&amp;nbsp; Autodesk is gifted and making ways for us to keep using and/or purchasing the latest and greatest software. So for our firm. This should suffice.&lt;/P&gt;
&lt;P&gt;Thanks again.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Feb 2019 18:08:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-entsel/m-p/8567352#M93348</guid>
      <dc:creator>DC-MWA</dc:creator>
      <dc:date>2019-02-01T18:08:47Z</dc:date>
    </item>
  </channel>
</rss>

