<?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: Drawing a number for every block in a drawing in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/drawing-a-number-for-every-block-in-a-drawing/m-p/7530349#M112255</link>
    <description>&lt;P&gt;Oh, my bad. None of those either. No xrefs in the current space.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/ts&lt;/P&gt;</description>
    <pubDate>Thu, 09 Nov 2017 12:29:22 GMT</pubDate>
    <dc:creator>thomas.schive</dc:creator>
    <dc:date>2017-11-09T12:29:22Z</dc:date>
    <item>
      <title>Drawing a number for every block in a drawing</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/drawing-a-number-for-every-block-in-a-drawing/m-p/7529955#M112251</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dwg with a lot of blocks, and I'd like to do the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Count all the blocks in the drawing&lt;/P&gt;&lt;P&gt;- Insert a number (1, 2, 3, 4 ... etc.) just as a text with an insertion point somewhere close to the block for every block found in the drawing. I think that the first could be specified by the user and then it could count itself.&lt;/P&gt;&lt;P&gt;- Create a new layer for the inserted numbers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any tips to get this to work as a LISP routine?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far I've begun working with some pieces, as to setq all the blocks I used:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(setq allblocks&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (sssetfirst nil&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (ssget "X" (list (cons 0 "INSERT")))&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which seems to work fine as to select all the blocks at least, allthough some VLA-functions might to the job better?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll also guess that the insert text-function could be solved using eval and append, but I'm not quite sure how yet ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/ts&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 09:39:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/drawing-a-number-for-every-block-in-a-drawing/m-p/7529955#M112251</guid>
      <dc:creator>thomas.schive</dc:creator>
      <dc:date>2017-11-09T09:39:52Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing a number for every block in a drawing</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/drawing-a-number-for-every-block-in-a-drawing/m-p/7530314#M112252</link>
      <description>&lt;P&gt;As a start....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would save that allblocks variable differently.&amp;nbsp; As you have it, what gets set into that variable isn't a selection set, but &lt;EM&gt;what the (sssetfirst) function returns&lt;/EM&gt;, which is a &lt;EM&gt;list&lt;/EM&gt;&amp;nbsp; in which the selection is the second item:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(nil &amp;lt;Selection set: XXX&amp;gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That will require an extra step to get that selection into a variable of its own, so that the routine can step through it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would save the selection set directly [in a little more concise way], and &lt;EM&gt;then&lt;/EM&gt;&amp;nbsp; if you want it highlighted as the rest of the routine does its thing [which shouldn't be necessary], do that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(setq allblocks (ssget "_X" '((0 . "INSERT"))))&lt;/P&gt;
&lt;P&gt;(sssetfirst nil allblocks)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That selection will include any Xrefs in the drawing&amp;nbsp;-- would you have any of those, and if so, should they also be numbered?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That will also include things in&amp;nbsp;all spaces.&amp;nbsp; If you want only those in the &lt;EM&gt;current&lt;/EM&gt;&amp;nbsp; space [which makes labeling them easier], the (ssget) filter can limit the selection that way.&amp;nbsp; Or if you want them in all spaces, the&amp;nbsp;routine can be made to move around among them to label everything.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Say more about what you mean by "somewhere close to the Block" for a Text location.&amp;nbsp; It would be easiest if the Text can have its insertion point &lt;EM&gt;at the Block's insertion point&lt;/EM&gt;.&amp;nbsp; But that assumes the insertion points are in some logical relationship to, and presumably within, the Blocks' content objects.&amp;nbsp; If Blocks are not well defined, and some insertion points may be off in the hinterlands somewhere, that won't&amp;nbsp;give helpful results.&amp;nbsp; In such a case, it would be necessary to dig out the Block's bounding box and use that somehow to place the Text.&amp;nbsp; But if they are well defined, let's take the example of a Block whose insertion point is in the center -- would it be acceptable to number it in the middle of it, or do you need the number &lt;EM&gt;outside&lt;/EM&gt;&amp;nbsp; but somewhere close?&amp;nbsp; [That would also require bounding-box operations.]&amp;nbsp; In what direction?&amp;nbsp; How close?&amp;nbsp; etc....&amp;nbsp; And would some Blocks be close enough to each other that a Text label "somewhere close to" one Block could overlap another Block?&amp;nbsp; Is that a problem?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 12:25:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/drawing-a-number-for-every-block-in-a-drawing/m-p/7530314#M112252</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2017-11-09T12:25:15Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing a number for every block in a drawing</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/drawing-a-number-for-every-block-in-a-drawing/m-p/7530320#M112253</link>
      <description>&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There will be no blocks in xrefs here. Current space should be enough.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/ts&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 12:18:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/drawing-a-number-for-every-block-in-a-drawing/m-p/7530320#M112253</guid>
      <dc:creator>thomas.schive</dc:creator>
      <dc:date>2017-11-09T12:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing a number for every block in a drawing</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/drawing-a-number-for-every-block-in-a-drawing/m-p/7530347#M112254</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4989462"&gt;@thomas.schive&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;....&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There will be no blocks in xrefs here. Current space should be enough.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
....&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I wasn't asking about Blocks &lt;EM&gt;in&lt;/EM&gt;&amp;nbsp; Xrefs, but Xrefs themselves, which are also "INSERT"-class objects that (ssget) will find.&amp;nbsp; If there would be no Xrefs in the current space, we're good.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[And I think we crossed in the mail -- I added some more to the end of Post 2 in the meantime.]&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 12:29:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/drawing-a-number-for-every-block-in-a-drawing/m-p/7530347#M112254</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2017-11-09T12:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing a number for every block in a drawing</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/drawing-a-number-for-every-block-in-a-drawing/m-p/7530349#M112255</link>
      <description>&lt;P&gt;Oh, my bad. None of those either. No xrefs in the current space.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/ts&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 12:29:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/drawing-a-number-for-every-block-in-a-drawing/m-p/7530349#M112255</guid>
      <dc:creator>thomas.schive</dc:creator>
      <dc:date>2017-11-09T12:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing a number for every block in a drawing</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/drawing-a-number-for-every-block-in-a-drawing/m-p/7530373#M112256</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hello Thomas&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe this routine "B2P - Block2Point" could help you and can be a GOOD starting point of your routine !?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;French Humour: it has been written a by Lisp Beginner !!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards, Patrice&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 12:41:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/drawing-a-number-for-every-block-in-a-drawing/m-p/7530373#M112256</guid>
      <dc:creator>braudpat</dc:creator>
      <dc:date>2017-11-09T12:41:45Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing a number for every block in a drawing</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/drawing-a-number-for-every-block-in-a-drawing/m-p/7530595#M112257</link>
      <description>&lt;P&gt;So far I've got something like this, that writes out my total amount of blocks in the beginning and a number for every place I click (getpoint) / so if I click at the blocks I'll get my number (+1 for every time):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(princ "Skriv TBP for aa kjoere LISPen")&lt;BR /&gt;(defun c:TBP ( / punkta)&lt;BR /&gt;(setq allblocks (ssget "X" (list (cons 0 "INSERT"))))&lt;BR /&gt;(setq T_count 0)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;(foreach block (ssnamex allblocks)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;(setq T_count (1+ T_count))&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;)&lt;BR /&gt;(princ T_count)&lt;BR /&gt;(setq T_count 0)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;(while (setq&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;punkta (getpoint "\nVelg punkt "))&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;(setq T_count (1+ T_count))&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;(eval (append '(command "._text" punkta)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;(if (zerop (cdr (assoc 40 (entget (tblobjname "style" (getvar 'textstyle))))))&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;'(0.12))&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;'(0 (rtos T_count 2 0)))))&lt;BR /&gt;(princ)&lt;BR /&gt;);_ defun&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I'd like it to skip the "getpoint"-part and just draw the numbers itself, and here's where I'm stuck.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/ts&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 13:35:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/drawing-a-number-for-every-block-in-a-drawing/m-p/7530595#M112257</guid>
      <dc:creator>thomas.schive</dc:creator>
      <dc:date>2017-11-09T13:35:09Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing a number for every block in a drawing</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/drawing-a-number-for-every-block-in-a-drawing/m-p/7530830#M112258</link>
      <description>&lt;P&gt;Here's a way to do it [lightly tested and without some of the usual enhancements]:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun c:TBP (/ allblocks int n)
  (prompt "\nTo Label Blocks with incrementing numbers,")
  (if (setq allblocks (ssget "_X" (list '(0 . "INSERT") (cons 410 (getvar 'ctab)))))
    (if (setq int (getint "\nStarting number or &amp;lt;exit&amp;gt;: "))
      (progn
        (repeat (setq n (sslength allblocks)) ; then
          (command "_.text" "_style" "&lt;EM&gt;&lt;FONT color="#00CCFF"&gt;YourDesiredStyle&lt;/FONT&gt;&lt;/EM&gt;"
            "_mc" "_none" (cdr (assoc 10 (entget (ssname allblocks (setq n (1- n))))))
              ;; Middle-Center-justified insertion point at Block's
            &lt;EM&gt;&lt;FONT color="#FF9900"&gt;YourDesiredHeight&lt;/FONT&gt;&lt;/EM&gt; 0 (itoa int); height, rotation &amp;amp; text content&lt;BR /&gt;              &lt;FONT color="#FF9900"&gt;;; &lt;EM&gt;omit height if Style is fixed-height&lt;/EM&gt;&lt;/FONT&gt;
          ); command
          (setq int (1+ int))
        ); repeat
      ); progn
      (prompt "\nFunction terminated at User request."); else
    ); if
    (prompt "\nNo Block(s) found in current space."); else
  ); if
  (princ)
); defun&lt;/PRE&gt;
&lt;P&gt;That puts the numbers middle-center justified at the Blocks' insertion points. &amp;nbsp;See the various questions at the end of Post 2.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 14:47:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/drawing-a-number-for-every-block-in-a-drawing/m-p/7530830#M112258</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2017-11-09T14:47:26Z</dc:date>
    </item>
  </channel>
</rss>

