<?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: LISp for area and length in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-for-area-and-length/m-p/11300548#M43294</link>
    <description>&lt;P&gt;Regards&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3978359"&gt;@Steve_-B&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here I show you my simple proposal, using only Vanilla autolisp.&lt;BR /&gt;For open polylines it calculates only length, for closed polylines it calculates length and area.&lt;BR /&gt;&lt;U&gt;Important note&lt;/U&gt;: Works with any text style similar to Standard (height=0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(defun c:apl (/ s a p h pt l)
  (setq s (entsel "\nSelect Lwpolyline: "))
  (command "_area" "_o" (car s))
  (setq a  (getvar 'area)
        p  (getvar 'perimeter)
        h  (getreal "\nEnter Height Text: ")
        pt (cadr s)
        l  (cdr (assoc 8 (entget (car s))))
        tl (strcat "\nL= " (rtos (* p 1e+3) 2 2) " mm")
        ta (strcat "\nL= " (rtos (* p 1e+3) 2 2) " mm" "; " "A= " (rtos a 2 2) " m2")
  )
  (if (= (cdr (assoc 70 (entget (car s)))) 128)
    (command "_text" "_near" pt h 0.0 tl)
    (command "_text" "_near" pt h 0.0 ta)
  )
  (command "_chprop" (entlast) "" "la" l "")
)&lt;/LI-CODE&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 15 Jul 2022 23:45:08 GMT</pubDate>
    <dc:creator>calderg1000</dc:creator>
    <dc:date>2022-07-15T23:45:08Z</dc:date>
    <item>
      <title>LISp for area and length</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-for-area-and-length/m-p/11299238#M43288</link>
      <description>&lt;P&gt;First post so please go easy if I'm posting in wrong forum.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, I'm trying to find a way to write a script to state the length against all open polyines and state the area inside all closed polylines in one macro.&amp;nbsp; I've found a macro for each task but have no idea how to combine them.&amp;nbsp; I also need the length/area tex to be on the same layer as the line they reference.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something like the below as I need to take of lots of information from plans and constantly clicking a line and then looking at the properties and copying to Excel is very time consuming.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GaiaSPB_0-1657877822174.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1092076i2FE8A417F4CC2C4D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="GaiaSPB_0-1657877822174.png" alt="GaiaSPB_0-1657877822174.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any assistance would be much appreciated.&amp;nbsp; Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jul 2022 09:38:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-for-area-and-length/m-p/11299238#M43288</guid>
      <dc:creator>Steve_-B</dc:creator>
      <dc:date>2022-07-15T09:38:12Z</dc:date>
    </item>
    <item>
      <title>Re: LISp for area and length</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-for-area-and-length/m-p/11299456#M43289</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3978359"&gt;@Steve_-B&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;....&amp;nbsp; I've found a macro for each task but have no idea how to combine them.&amp;nbsp; ...&lt;/SPAN&gt;.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Post them.&amp;nbsp; Someone could much more easily show you how to combine them than come up with an approach from scratch [or find things to combine in this Forum].&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jul 2022 12:21:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-for-area-and-length/m-p/11299456#M43289</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2022-07-15T12:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: LISp for area and length</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-for-area-and-length/m-p/11299513#M43290</link>
      <description>&lt;P&gt;Try this one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(vl-load-com)

(defun c:PLenarea  (/ spc doc s i l e o vrs pts oid pnt fld txt)
  
  (setq spc (vla-get-modelspace (setq doc (vla-get-activedocument (vlax-get-acad-object)))))
  (vla-startundomark doc)
  
  (if (setq s (ssget '((0 . "CIRCLE,LWPOLYLINE,LINE,ARC"))))
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i)))
	    o (vlax-ename-&amp;gt;vla-object e)
	    l (cdr (assoc 8 (entget e))))
      (if (or (= "CIRCLE" (cdr (assoc 0 (entget e))))
	      (and (= "LWPOLYLINE" (cdr (assoc 0 (entget e))))
		   (= 1 (getpropertyvalue e "Closed"))))
	(setq vrs (cond ((cdr (assoc 90 (entget e)))) (1))
	      pts (apply 'mapcar (cons '+ (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget e)))))
	      pnt (mapcar '/ pts (list vrs vrs))		 
	      oid (itoa (vla-get-objectid o))
	      fld (strcat "%&amp;lt;\\AcObjProp Object(%&amp;lt;\\_ObjId " oid "&amp;gt;%).Area \\f \"%lu2%ps[, m2]%ct8[1.0E-006]\"&amp;gt;%"))
	(setq pnt (vlax-curve-getpointatdist e (/ (vlax-curve-getdistatparam e (vlax-curve-getendparam e)) 2))
	      oid (itoa (vla-get-objectid o))
	      fld (strcat "%&amp;lt;\\AcObjProp Object(%&amp;lt;\\_ObjId " oid "&amp;gt;%).Length \\f \"%lu2%ps[, m]%ct8[1.0E-003]\"&amp;gt;%")))
      (setq txt (vla-addMText spc (setq pnt (vlax-3d-point pnt)) 0 fld))
      (vla-put-layer txt l)
      (vla-put-AttachmentPoint txt acAttachmentPointMiddleCenter)
      (vla-put-InsertionPoint txt pnt)
      ))
  (vla-endundomark doc)
  (princ)
  )
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jul 2022 13:19:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-for-area-and-length/m-p/11299513#M43290</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2022-07-15T13:19:06Z</dc:date>
    </item>
    <item>
      <title>Re: LISp for area and length</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-for-area-and-length/m-p/11299542#M43291</link>
      <description>&lt;P&gt;Wow, that is really good and just what I need.&amp;nbsp; I appreciate your help and don't want to abuse it but is there a way to get the text to adopt the layer of the line it's referencing?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also need to change the units (my drawings are in mm and mm2 but I want the text to be m2 as you've put in your code), also decimal points and rounding up to the nearest single decimal point.&amp;nbsp; However I want to try and work this out myself as don't want to take liberties.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks again&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jul 2022 12:54:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-for-area-and-length/m-p/11299542#M43291</guid>
      <dc:creator>Steve_-B</dc:creator>
      <dc:date>2022-07-15T12:54:54Z</dc:date>
    </item>
    <item>
      <title>Re: LISp for area and length</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-for-area-and-length/m-p/11299586#M43292</link>
      <description>&lt;P&gt;Ok, code updated.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jul 2022 13:22:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-for-area-and-length/m-p/11299586#M43292</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2022-07-15T13:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: LISp for area and length</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-for-area-and-length/m-p/11299722#M43293</link>
      <description>&lt;P&gt;thank you so much&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jul 2022 14:20:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-for-area-and-length/m-p/11299722#M43293</guid>
      <dc:creator>Steve_-B</dc:creator>
      <dc:date>2022-07-15T14:20:31Z</dc:date>
    </item>
    <item>
      <title>Re: LISp for area and length</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-for-area-and-length/m-p/11300548#M43294</link>
      <description>&lt;P&gt;Regards&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3978359"&gt;@Steve_-B&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here I show you my simple proposal, using only Vanilla autolisp.&lt;BR /&gt;For open polylines it calculates only length, for closed polylines it calculates length and area.&lt;BR /&gt;&lt;U&gt;Important note&lt;/U&gt;: Works with any text style similar to Standard (height=0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(defun c:apl (/ s a p h pt l)
  (setq s (entsel "\nSelect Lwpolyline: "))
  (command "_area" "_o" (car s))
  (setq a  (getvar 'area)
        p  (getvar 'perimeter)
        h  (getreal "\nEnter Height Text: ")
        pt (cadr s)
        l  (cdr (assoc 8 (entget (car s))))
        tl (strcat "\nL= " (rtos (* p 1e+3) 2 2) " mm")
        ta (strcat "\nL= " (rtos (* p 1e+3) 2 2) " mm" "; " "A= " (rtos a 2 2) " m2")
  )
  (if (= (cdr (assoc 70 (entget (car s)))) 128)
    (command "_text" "_near" pt h 0.0 tl)
    (command "_text" "_near" pt h 0.0 ta)
  )
  (command "_chprop" (entlast) "" "la" l "")
)&lt;/LI-CODE&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jul 2022 23:45:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-for-area-and-length/m-p/11300548#M43294</guid>
      <dc:creator>calderg1000</dc:creator>
      <dc:date>2022-07-15T23:45:08Z</dc:date>
    </item>
    <item>
      <title>Re: LISp for area and length</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-for-area-and-length/m-p/11306468#M43295</link>
      <description>&lt;P&gt;thank you&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 14:44:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-for-area-and-length/m-p/11306468#M43295</guid>
      <dc:creator>Steve_-B</dc:creator>
      <dc:date>2022-07-19T14:44:41Z</dc:date>
    </item>
  </channel>
</rss>

