<?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: Count Number of Block Inside a Polygon then Update the Table Using LISP in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/count-number-of-block-inside-a-polygon-then-update-the-table/m-p/9577956#M73375</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/564264"&gt;@pbejse&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Almost there the only problem is the count is always short by 1 unit&lt;/P&gt;</description>
    <pubDate>Sat, 13 Jun 2020 12:08:47 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-06-13T12:08:47Z</dc:date>
    <item>
      <title>Count Number of Block Inside a Polygon then Update the Table Using LISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/count-number-of-block-inside-a-polygon-then-update-the-table/m-p/9577706#M73373</link>
      <description>&lt;P&gt;Hello, Experts!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you have a lisp that can count the number of blocks listed inside a polygon then updates the table with the correct count?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I attached the dwg file for testing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LISP should work like this:&lt;/P&gt;&lt;P&gt;User: Run the command.&lt;/P&gt;&lt;P&gt;User: Select Polygon.&lt;/P&gt;&lt;P&gt;Program: Count the number of B1 &amp;amp; B2 inside the Polygon but disregard B3.&lt;/P&gt;&lt;P&gt;Program: Pop up message "Table is Updated"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jun 2020 04:04:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/count-number-of-block-inside-a-polygon-then-update-the-table/m-p/9577706#M73373</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-06-13T04:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: Count Number of Block Inside a Polygon then Update the Table Using LISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/count-number-of-block-inside-a-polygon-then-update-the-table/m-p/9577754#M73374</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello, Experts!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you have a lisp that can count the number of blocks listed inside a polygon then updates the table with the correct count?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I attached the dwg file for testing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;LISP should work like this:&lt;/P&gt;
&lt;P&gt;User: Run the command.&lt;/P&gt;
&lt;P&gt;User: Select Polygon.&lt;/P&gt;
&lt;P&gt;Program: Count the number of B1 &amp;amp; B2 inside the Polygon but disregard B3.&lt;/P&gt;
&lt;P&gt;Program: Pop up message "Table is Updated"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;(defun c:demo (/ col ss blk strs n el bn tgnme pts)
  (Setq	lst
	 '(("B1" "B1C")
	   ("B2" "B2C")
	  )
  )
  (if
    (and
      (setq coll nil
	    ss	 (ssget '((0 . "LWPOLYLINE")))
      )
      (setq blk (ssget "_X" '((0 . "INSERT") (2 . "BTable"))))
    )
     (progn
       (repeat (setq i (sslength ss))
	 (setq e   (ssname ss (setq i (1- i)))
	       pts (mapcar 'cdr
			   (vl-remove-if-not
			     '(lambda (x) (= (car x) 10))
			     (entget e)
			   )
		   )
	 )
	 (if
	   (setq strs (ssget "_CP" pts '((0 . "INSERT") (2 . "B1,B2"))))
	    (repeat (setq n (sslength strs))
	      (setq e1 (ssname strs (setq n (1- n)))
		    bn (getpropertyvalue e1 "BlockTableRecord/Name")
	      )
	      (if (Setq f (assoc bn coll))
		(setq coll (subst (list bn (1+ (cadr f))) f coll))
		(setq coll (cons (list bn 0) coll))
		      )
		    )
		 )
	       )
	(and
	       (foreach	itm coll
		 (setq tgnme (assoc (Car itm) lst))
		 (setpropertyvalue
		   (ssname blk 0)
		   (cadr tgnme)
		   (itoa (Cadr itm))
		 )
		 itm
	       )
       		(alert "Table is Updated")
		   )
	     	)    
	   )
  (princ)
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTH&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jun 2020 05:44:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/count-number-of-block-inside-a-polygon-then-update-the-table/m-p/9577754#M73374</guid>
      <dc:creator>pbejse</dc:creator>
      <dc:date>2020-06-13T05:44:50Z</dc:date>
    </item>
    <item>
      <title>Re: Count Number of Block Inside a Polygon then Update the Table Using LISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/count-number-of-block-inside-a-polygon-then-update-the-table/m-p/9577956#M73375</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/564264"&gt;@pbejse&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Almost there the only problem is the count is always short by 1 unit&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jun 2020 12:08:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/count-number-of-block-inside-a-polygon-then-update-the-table/m-p/9577956#M73375</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-06-13T12:08:47Z</dc:date>
    </item>
    <item>
      <title>Re: Count Number of Block Inside a Polygon then Update the Table Using LISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/count-number-of-block-inside-a-polygon-then-update-the-table/m-p/9577963#M73376</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/564264"&gt;@pbejse&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Almost there the only problem is the count is always short by 1 unit&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;oops, my bad..&lt;/P&gt;
&lt;P&gt;change this..&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;(list bn 0) &lt;/LI-CODE&gt;
&lt;P&gt;to&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;(list bn 1) &lt;/LI-CODE&gt;
&lt;P&gt;HTH&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jun 2020 12:14:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/count-number-of-block-inside-a-polygon-then-update-the-table/m-p/9577963#M73376</guid>
      <dc:creator>pbejse</dc:creator>
      <dc:date>2020-06-13T12:14:43Z</dc:date>
    </item>
    <item>
      <title>Re: Count Number of Block Inside a Polygon then Update the Table Using LISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/count-number-of-block-inside-a-polygon-then-update-the-table/m-p/9577970#M73377</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/564264"&gt;@pbejse&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Exactly what i need!&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jun 2020 12:22:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/count-number-of-block-inside-a-polygon-then-update-the-table/m-p/9577970#M73377</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-06-13T12:22:58Z</dc:date>
    </item>
    <item>
      <title>Re: Count Number of Block Inside a Polygon then Update the Table Using LISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/count-number-of-block-inside-a-polygon-then-update-the-table/m-p/9577974#M73378</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/564264"&gt;@pbejse&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Exactly what i need!&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You are welcome, glad it works for you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jun 2020 12:24:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/count-number-of-block-inside-a-polygon-then-update-the-table/m-p/9577974#M73378</guid>
      <dc:creator>pbejse</dc:creator>
      <dc:date>2020-06-13T12:24:55Z</dc:date>
    </item>
    <item>
      <title>Re: Count Number of Block Inside a Polygon then Update the Table Using LISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/count-number-of-block-inside-a-polygon-then-update-the-table/m-p/9580577#M73379</link>
      <description>&lt;P&gt;very good and simple tool&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2020 16:15:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/count-number-of-block-inside-a-polygon-then-update-the-table/m-p/9580577#M73379</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-06-15T16:15:41Z</dc:date>
    </item>
  </channel>
</rss>

