<?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: Script help. How to update a get area script to round up the area to the nea in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-help-how-to-update-a-get-area-script-to-round-up-the-area/m-p/5451936#M145288</link>
    <description>&lt;P&gt;Any idea how would I apply this to the code in the OP.&amp;nbsp; I assume it would need to be applied in this portion of the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(strcat&amp;nbsp;"%&amp;lt;\\AcObjProp Object(%&amp;lt;\\_ObjId "&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;(if (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE"))&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (vlax-invoke-method&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (vla-get-Utility adoc)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'GetObjectIdString&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; obj&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :vlax-false&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (itoa (vla-get-Objectid obj))&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;"&amp;gt;%).Area \\f \"%pr0%lu2%ct4%qf1 SF.\"&amp;gt;%")&lt;BR /&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 23 Dec 2014 20:20:05 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2014-12-23T20:20:05Z</dc:date>
    <item>
      <title>Script help. How to update a get area script to round up the area to the neares</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-help-how-to-update-a-get-area-script-to-round-up-the-area/m-p/5451178#M145285</link>
      <description>&lt;P&gt;I have a script that finds an area of a polyline and creates a field&amp;nbsp;that list the area&amp;nbsp;and places the field in the polyline.&amp;nbsp; My only problem is I would like it to round the field up to the nearest 10 (example 323 would become 330).&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; See code below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;;; local defun
;; get center of closed object
(defun getcenter (obj / acsp cen rgn)
(setq acsp (vla-get-modelspace
	     (vla-get-activedocument
	       (vlax-get-acad-object)))
        rgn (car (vlax-invoke acsp 'Addregion (list obj)))
      cen (vlax-get rgn 'Centroid)
)
(vla-delete rgn)
cen
)

;; main part
;; label [plines w]/area field in sq. meters
(defun c:GAREA (/ acsp adoc axss cpt ins ss txt mtxtobj)
  (vl-load-com)  
  (or adoc
      (setq adoc (vla-get-activedocument
		   (vlax-get-acad-object)
		 )
      )
  )
  (or acsp
      (setq acsp (vla-get-modelspace
		   adoc
		 )
      )
  )

  (if
  (setq ss (ssget (list (cons 0 "*POLYLINE,*CONTOUR"))))
  (progn
  (setq axss (vla-get-activeselectionset adoc))
  ;; iterate through the active selection set collection
  (vlax-for obj axss
         ; get a curve center
         (setq cpt (trans (getcenter obj) 0 1))	 
	 (setq txt
	 ; displayed in meters to 3 decimal place:	
;;;		(strcat	"%&amp;lt;\\AcObjProp Object(%&amp;lt;\\_ObjId "
;;;			(itoa (vlax-get obj 'ObjectID))
;;;			"&amp;gt;%).Area \\f \"%lu2%pr3%ps[, m2]%ct8[1e-006]\"&amp;gt;%"
;;;		)
	 ; displayed in engineering to 2 decimal place:	
;	       (strcat	"%&amp;lt;\\AcObjProp Object(%&amp;lt;\\_ObjId "
;			(itoa (vlax-get obj 'ObjectID))
;			"&amp;gt;%).Area \\f \"%pr2%lu2%ct4%qf1\"&amp;gt;%");&amp;lt;--pr2 means 2 decimal places, change to your suit
	 ; displayed in engineering to 2 decimal place with addition SQ. FT.:
	       (strcat	"%&amp;lt;\\AcObjProp Object(%&amp;lt;\\_ObjId "
			(if (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE"))
			  (vlax-invoke-method
			    (vla-get-Utility adoc)
			    'GetObjectIdString
			    obj
			    :vlax-false
			  )
			  (itoa (vla-get-Objectid obj))
			)
			"&amp;gt;%).Area \\f \"%pr0%lu2%ct4%qf1 SF.\"&amp;gt;%")
	 )
; add mtext object to model space
(setq mtxtobj (vlax-invoke
	       acsp 'AddMText
	       	 cpt ;insertion point
	       0.0 ; mtext width, optional = 0
		txt ;string (field value)
	       ))
; change mtext height accordingly to current dimension style text height:
;(vlax-put mtxtobj 'Height (getvar "dimtxt")); change (getvar "dimtxt") on text height you need
(vlax-put mtxtobj 'Height "11")
; set justifying to middle center
(vlax-put  mtxtobj  'AttachmentPoint acAttachmentPointMiddleCenter)  
       )      
     )
  )
     (vla-regen adoc acactiveviewport)

  (princ)
)
(princ "\n   Type GAREA to label objects with area field")
(princ)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Dec 2014 00:44:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-help-how-to-update-a-get-area-script-to-round-up-the-area/m-p/5451178#M145285</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-12-23T00:44:59Z</dc:date>
    </item>
    <item>
      <title>Re: Script help. How to update a get area script to round up the area to the nea</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-help-how-to-update-a-get-area-script-to-round-up-the-area/m-p/5451588#M145286</link>
      <description>(setq NN 323)&lt;BR /&gt;(setq NN (* (fix (/ NN 10)) 10))&lt;BR /&gt;</description>
      <pubDate>Tue, 23 Dec 2014 15:39:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-help-how-to-update-a-get-area-script-to-round-up-the-area/m-p/5451588#M145286</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-12-23T15:39:32Z</dc:date>
    </item>
    <item>
      <title>Re: Script help. How to update a get area script to round up the area to the nea</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-help-how-to-update-a-get-area-script-to-round-up-the-area/m-p/5451615#M145287</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;(setq NN 323)&lt;BR /&gt;(setq NN (* (fix (/ NN 10)) 10))&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN class="hps alt-edited"&gt;I would suggest&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hps alt-edited"&gt;(setq NN (* (fix (/ (+ NN 5) 10)) 10))&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hps alt-edited"&gt;323 would return 320&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hps alt-edited"&gt;325 would return 330&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hps alt-edited"&gt;Henrique&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Dec 2014 15:58:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-help-how-to-update-a-get-area-script-to-round-up-the-area/m-p/5451615#M145287</guid>
      <dc:creator>hmsilva</dc:creator>
      <dc:date>2014-12-23T15:58:11Z</dc:date>
    </item>
    <item>
      <title>Re: Script help. How to update a get area script to round up the area to the nea</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-help-how-to-update-a-get-area-script-to-round-up-the-area/m-p/5451936#M145288</link>
      <description>&lt;P&gt;Any idea how would I apply this to the code in the OP.&amp;nbsp; I assume it would need to be applied in this portion of the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(strcat&amp;nbsp;"%&amp;lt;\\AcObjProp Object(%&amp;lt;\\_ObjId "&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;(if (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE"))&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (vlax-invoke-method&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (vla-get-Utility adoc)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'GetObjectIdString&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; obj&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :vlax-false&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (itoa (vla-get-Objectid obj))&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;"&amp;gt;%).Area \\f \"%pr0%lu2%ct4%qf1 SF.\"&amp;gt;%")&lt;BR /&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Dec 2014 20:20:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-help-how-to-update-a-get-area-script-to-round-up-the-area/m-p/5451936#M145288</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-12-23T20:20:05Z</dc:date>
    </item>
    <item>
      <title>Re: Script help. How to update a get area script to round up the area to the nea</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-help-how-to-update-a-get-area-script-to-round-up-the-area/m-p/5452443#M145289</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;Any idea how would I apply this to the code in the OP.&amp;nbsp; I assume it would need to be applied in this portion of the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hello dglenn9000,&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hps"&gt;unfortunately&lt;/SPAN&gt; inches and feet are not my world, I'm a metric guy, &lt;SPAN class="hps alt-edited"&gt;I&amp;nbsp;had&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;some difficulty &lt;SPAN class="hps alt-edited"&gt;to round up&lt;/SPAN&gt; in square feet, &lt;SPAN class="hps alt-edited"&gt;probably&lt;/SPAN&gt; someone &lt;SPAN class="hps"&gt;used to using&lt;/SPAN&gt; &lt;SPAN class="hps alt-edited"&gt;those units&lt;/SPAN&gt; &lt;SPAN class="hps alt-edited"&gt;will give&lt;/SPAN&gt; you &lt;SPAN class="hps alt-edited"&gt;better help.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hps"&gt;&lt;SPAN class="hps alt-edited"&gt;If the outcome&amp;nbsp;was &lt;SPAN class="hps"&gt;in&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;default&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;units (with no &lt;SPAN class="hps"&gt;conversion factor&lt;/SPAN&gt;) I &lt;SPAN class="hps"&gt;would use&lt;/SPAN&gt; &lt;SPAN class="hps alt-edited"&gt;something like this&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(strcat "%&amp;lt;\\AcExpr (1e1*trunc(%&amp;lt;\\AcObjProp Object(%&amp;lt;\\_ObjId "
        (if (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE"))
          (vlax-invoke-method
            (vla-get-Utility adoc)
            'GetObjectIdString
            obj
            :vlax-false
          )
          (itoa (vla-get-Objectid obj))
        )
        "&amp;gt;%).Area \\f \"%pr0%lu2 \"&amp;gt;%*1e-1)) \\f \"%pr0%lu2\"&amp;gt;%"
)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Dec 2014 11:56:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-help-how-to-update-a-get-area-script-to-round-up-the-area/m-p/5452443#M145289</guid>
      <dc:creator>hmsilva</dc:creator>
      <dc:date>2014-12-24T11:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: Script help. How to update a get area script to round up the area to the nea</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-help-how-to-update-a-get-area-script-to-round-up-the-area/m-p/5460970#M145290</link>
      <description>&lt;P&gt;For square feet, please give this a try.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is similar to what Henrique suggested but since the "round"&amp;nbsp;works on the original value and not on what is previewed, we need to handle the conversion on our own.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;   (strcat "%&amp;lt;\\AcExpr (1e1*round((%&amp;lt;\\AcObjProp Object(%&amp;lt;\\_ObjId "
			(if (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE"))
			  (vlax-invoke-method
			    (vla-get-Utility adoc)
			    'GetObjectIdString
			    obj
			    :vlax-false
			  )
			  (itoa (vla-get-Objectid obj))
			)
        "&amp;gt;%).Area \\f \"%pr0%lu2\"&amp;gt;%/144)*1e-1)) \\f \"%lu2%pr0%ps[, S F (rounded)]\"&amp;gt;%")&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Balaji&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jan 2015 10:00:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-help-how-to-update-a-get-area-script-to-round-up-the-area/m-p/5460970#M145290</guid>
      <dc:creator>Balaji_Ram</dc:creator>
      <dc:date>2015-01-07T10:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: Script help. How to update a get area script to round up the area to the nea</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-help-how-to-update-a-get-area-script-to-round-up-the-area/m-p/5460974#M145291</link>
      <description>&lt;P&gt;And here is a test drawing to try it with two mtext&amp;nbsp;inserted.&lt;/P&gt;
&lt;P&gt;One of them rounds it to nearest 10 while the other displays without a change.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Balaji&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jan 2015 10:07:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-help-how-to-update-a-get-area-script-to-round-up-the-area/m-p/5460974#M145291</guid>
      <dc:creator>Balaji_Ram</dc:creator>
      <dc:date>2015-01-07T10:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: Script help. How to update a get area script to round up the area to the nea</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-help-how-to-update-a-get-area-script-to-round-up-the-area/m-p/5846076#M145292</link>
      <description>&lt;P&gt;A little late in my reply but this works perfect.&amp;nbsp; Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Oct 2015 22:10:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-help-how-to-update-a-get-area-script-to-round-up-the-area/m-p/5846076#M145292</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-10-05T22:10:44Z</dc:date>
    </item>
  </channel>
</rss>

