<?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: Rounding down dimension values in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10609540#M56276</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3930636"&gt;@john.uhden&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;....&lt;BR /&gt;Command: (rounddown "5.009000000" 2)&lt;BR /&gt;"5.00"&lt;BR /&gt;Shouldn't the answer be "5.01?"&lt;BR /&gt;....&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not in this Topic -- that's what the "down" part is about.&amp;nbsp; See the topic title and Message 1.&lt;/P&gt;</description>
    <pubDate>Thu, 09 Sep 2021 00:57:04 GMT</pubDate>
    <dc:creator>Kent1Cooper</dc:creator>
    <dc:date>2021-09-09T00:57:04Z</dc:date>
    <item>
      <title>Rounding down dimension values</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10584153#M56253</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;Please help me, I would like a LISP to round down existing dimension values, for example:&lt;/P&gt;&lt;P&gt;5,87-&amp;gt; 5,80&lt;/P&gt;&lt;P&gt;6,79-&amp;gt;6,70&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One important thing is that the value the lisp would get to round is the real value of the dimension, in case that dimension changes in the future so I can run the lisp again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've searched a lot and I only found a lisp to round up, and it's in feets&amp;amp;inches.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much!&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 09:52:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10584153#M56253</guid>
      <dc:creator>curro.aguilera</dc:creator>
      <dc:date>2021-08-30T09:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding down dimension values</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10584302#M56254</link>
      <description>&lt;P&gt;Try this.&amp;nbsp; Returns rounded number to n decimal places as a string. Not thoroughly tested but it serves me for years.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(defun round  (num places / neg ret b  a1 poz _r portions i frac n) ;
    (defun minusp (num) (cond ((numberp num) (&amp;lt; num 0.0))))
    (setq 
        neg (minusp num)
        places (abs places)
        a1 (rtos num 2 places)
        poz(vl-string-position (ascii ".") a1)
    )
    (if poz 
        (progn (setq _rem (substr a1 1 (+ poz 1)))
               (setq frac (vl-string-left-trim _rem a1))
        )
        (setq frac "")
    )
    (setq num (abs num)  _r (rem num 1.0) num (- num _r))
    (if (and(&amp;gt; _r  0.5)(eq places 0)) (setq num (+ num 1)))
        (while (&amp;gt; num 0.0)
            (setq portions (cons (fix (rem num 1000.0)) portions)
                  num (/ (- num (car portions)) 1000.0)
            )
        )
        (setq n (length portions) i 0 ret "")
        (while (&amp;lt; i n)
            (setq b (rtos (nth i portions) 2 0))
            (if (and (eq (strlen b)1) (&amp;gt; i 0)) (setq b (strcat "00" b)))
            (if (and (eq (strlen b)2) (&amp;gt; i 0)) (setq b (strcat "0" b)))
            (setq ret (strcat ret b " "))
            (setq i (+ i 1))
        )
        (setq ret(substr ret 1 (- (strlen ret) 1)))
        (if (&amp;gt; places 0 )(setq ret (strcat ret "." frac)))
        (if neg (setq ret (strcat "-" ret)))
     ret
)&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;</description>
      <pubDate>Mon, 30 Aug 2021 11:00:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10584302#M56254</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2021-08-30T11:00:05Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding down dimension values</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10584335#M56255</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;Thank you very much for you help, but I can't make it work.&lt;/P&gt;&lt;P&gt;Tried changing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(defun round  (num places / neg ret b  a1 poz _r portions i frac n) ;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(defun c:round  (num places / neg ret b  a1 poz _r portions i frac n) ;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but it returns me an error "not enough arguments" (my AutoCAD is in spanish, so that would be the aproximated translation).&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="curroaguilera_0-1630322142786.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/958867i7CBB96221E25F349/image-size/medium?v=v2&amp;amp;px=400" role="button" title="curroaguilera_0-1630322142786.png" alt="curroaguilera_0-1630322142786.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Do you have any idea of what it isn't working?&lt;/P&gt;&lt;P&gt;Thank you very much!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 11:15:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10584335#M56255</guid>
      <dc:creator>curro.aguilera</dc:creator>
      <dc:date>2021-08-30T11:15:14Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding down dimension values</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10584366#M56256</link>
      <description>&lt;P&gt;Your example shows two decimal places, with the second one always being zero.&amp;nbsp; Is that what you want?&amp;nbsp; If the second decimal place is always zero, can it not be omitted?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want the extraneous 0, try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;(defun C:RDD10 ; = Round Dimension Down to 1 decimal place + 0
  (/ dim)
  (setq dim (car (entsel "\nSelect Dimension: ")))
  (setpropertyvalue dim "DimensionText"
    (strcat (rtos (/ (fix (* (getpropertyvalue dim "Measurement") 10)) 10.0) 2 1) "0")
  ); setpropertyvalue
); defun&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you can do without the extraneous 0, this does the same without adding that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;(defun C:RDD1 ; = Round Dimension Down to 1 decimal place
  (/ dim)
  (setq dim (car (entsel "\nSelect Dimension: ")))
  (setpropertyvalue dim "DimensionText"
    (rtos (/ (fix (* (getpropertyvalue dim "Measurement") 10)) 10.0) 2 1)
  ); setpropertyvalue
); defun&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Either could be improved, such as to verify that you selected the right kind of thing, to ask again if you miss or pick something else, and/or to ask how many decimal places you want, etc.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 12:07:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10584366#M56256</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2021-08-30T12:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding down dimension values</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10584385#M56257</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(defun c:round_dimensions (/ round n e ent r)

	(defun round  (num places / neg ret b  a1 poz _r portions i frac n) ;
		(defun minusp (num) (cond ((numberp num) (&amp;lt; num 0.0))))
		(setq 
			neg (minusp num)
			places (abs places)
			a1 (rtos num 2 places)
			poz(vl-string-position (ascii ".") a1)
		)
		(if poz 
			(progn (setq _rem (substr a1 1 (+ poz 1)))
				   (setq frac (vl-string-left-trim _rem a1))
			)
			(setq frac "")
		)
		(setq num (abs num)  _r (rem num 1.0) num (- num _r))
		(if (and(&amp;gt; _r  0.5)(eq places 0)) (setq num (+ num 1)))
			(while (&amp;gt; num 0.0)
				(setq portions (cons (fix (rem num 1000.0)) portions)
					  num (/ (- num (car portions)) 1000.0)
				)
			)
			(setq n (length portions) i 0 ret "")
			(while (&amp;lt; i n)
				(setq b (rtos (nth i portions) 2 0))
				(if (and (eq (strlen b)1) (&amp;gt; i 0)) (setq b (strcat "00" b)))
				(if (and (eq (strlen b)2) (&amp;gt; i 0)) (setq b (strcat "0" b)))
				(setq ret (strcat ret b " "))
				(setq i (+ i 1))
			)
			(setq ret(substr ret 1 (- (strlen ret) 1)))
			(if (&amp;gt; places 0 )(setq ret (strcat ret "." frac)))
			(if neg (setq ret (strcat "-" ret)))
		 ret
	)
	(setq n (getint "\Number of places &amp;gt;"))
	(while (setq e (car(entsel "\nSelect dimension to round")))
		(setq ent (entget e))
		(cond 
			((= (cdr (assoc 0 ent)) "DIMENSION")
				(setq con (cdr(assoc 42 ent)))
				(setq r (round con n))
				(setq ent (subst (cons 1 r) (assoc 1 ent) ent))
				(entmod ent)	
			)
		)
	)
(princ)
)&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 30 Aug 2021 11:49:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10584385#M56257</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2021-08-30T11:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding down dimension values</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10584410#M56258</link>
      <description>&lt;P&gt;Hi!! &lt;EM&gt;edit: I changed my mind, I definitely want it without the zero! So I used the second solution&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Your solution works perfect, but i would like to select more than one dimension at once! Could be possible? Or even running the lisp on the selected dimensions (previous to calling the lisp)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very very much!!!&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 12:11:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10584410#M56258</guid>
      <dc:creator>curro.aguilera</dc:creator>
      <dc:date>2021-08-30T12:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding down dimension values</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10584420#M56259</link>
      <description>&lt;P&gt;Hi! Thank you again!!! But I cannot manage it to work. It ask me to select a dimension, I click it but nothing happens&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 11:59:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10584420#M56259</guid>
      <dc:creator>curro.aguilera</dc:creator>
      <dc:date>2021-08-30T11:59:29Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding down dimension values</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10584583#M56260</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/10888219"&gt;@curro.aguilera&lt;/a&gt;&amp;nbsp; Attach your sample drawing. Also, what is your decimal separator "." or ",".&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 13:00:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10584583#M56260</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2021-08-30T13:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding down dimension values</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10584630#M56261</link>
      <description>&lt;P&gt;Try this. If works OK for me. Try with different number of decimal places, and change decimal separator id apply.&lt;/P&gt;&lt;P&gt;In your case n = 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(defun c:round_dimensions (/ round n ss i ent con r)

	(defun round  (num places / neg ret b  a1 poz _r portions i frac n) ;
		(defun minusp (num) (cond ((numberp num) (&amp;lt; num 0.0))))
		(setq 
			neg (minusp num)
			places (abs places)
			a1 (rtos num 2 places)
			poz(vl-string-position (ascii ".") a1)
		)
		(if poz 
			(progn (setq _rem (substr a1 1 (+ poz 1)))
				   (setq frac (vl-string-left-trim _rem a1))
			)
			(setq frac "")
		)
		(setq num (abs num)  _r (rem num 1.0) num (- num _r))
		(if (and(&amp;gt; _r  0.5)(eq places 0)) (setq num (+ num 1)))
			(while (&amp;gt; num 0.0)
				(setq portions (cons (fix (rem num 1000.0)) portions)
					  num (/ (- num (car portions)) 1000.0)
				)
			)
			(setq n (length portions) i 0 ret "")
			(while (&amp;lt; i n)
				(setq b (rtos (nth i portions) 2 0))
				(if (and (eq (strlen b)1) (&amp;gt; i 0)) (setq b (strcat "00" b)))
				(if (and (eq (strlen b)2) (&amp;gt; i 0)) (setq b (strcat "0" b)))
				(setq ret (strcat ret b " "))
				(setq i (+ i 1))
			)
			(setq ret(substr ret 1 (- (strlen ret) 1)))
			(if (&amp;gt; places 0 )(setq ret (strcat ret "," frac)))  ;change decimal separator to comma if apply
			(if neg (setq ret (strcat "-" ret)))
		 ret
	)
	(setq n (getint "\Number of places &amp;gt;"))
	(setq ss (ssget "X" '((0 . "DIMENSION"))))
	(setq i -1)
	(cond 
		((and ss)
			(while (&amp;lt; (setq i (1+ i)) (sslength ss))
				(setq ent (entget (ssname ss i)))
				(setq con (cdr(assoc 42 ent)))
				(setq r (round con n))
				(setq ent (subst (cons 1 r) (assoc 1 ent) ent))
				(entmod ent)	
			)
		)
	)
(princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 13:13:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10584630#M56261</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2021-08-30T13:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding down dimension values</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10584665#M56262</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/10888219"&gt;@curro.aguilera&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;... i would like to select more than one dimension at once! Could be possible? ....&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you are willing to go around and pick them one at a time, but as many as you want in one running of the command, and have each one processed as you pick it, this is a simple adjustment:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;(defun C:RDD1 ; = Round Dimension Down to 1 decimal place
  (/ dim)
  (while (setq dim (car (entsel "\nSelect Dimension: ")))
    (setpropertyvalue dim "DimensionText"
      (rtos (/ (fix (* (getpropertyvalue dim "Measurement") 10)) 10.0) 2 1)
    ); setpropertyvalue
  ); while
); defun&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to select multiple Dimensions at one time, such as with a window and all the selection options, this will do that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;(defun C:RDD1 ; = Round Dimension Down to 1 decimal place
  (/ rddss n dim)
  (if (setq rddss (ssget '((0 . "DIMENSION"))))
    (repeat (setq n (sslength rddss)); then
      (setq dim (ssname rddss (setq n (1- n))))
      (if (not (wcmatch (cdr (assoc 100 (reverse (entget dim)))) "*Angular*"))
        (setpropertyvalue dim "DimensionText"
          (rtos (/ (fix (* (getpropertyvalue dim "Measurement") 10)) 10.0) 2 1)
        ); setpropertyvalue
      ); if
    ); repeat
  ); if
); defun&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That ignores &lt;EM&gt;Angular&lt;/EM&gt; Dimensions -- I had some in my test selection, and they use a different property name ["AngularMeasurement"], so they caused trouble.&amp;nbsp; If you want them rounded down, too, that can be accommodated with just a little more code.&amp;nbsp; But it does horizontal, vertical, rotated, aligned, ordinate, diameter, radius.&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;EDIT:&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp; Here's a version that asks for the number of decimal places, and remembers your choice to offer as default on subsequent use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;(defun C:RDD ; = Round Dimension Down
  (/ rddss n dim)
  (initget 4); no negative
  (setq _RDDdp_ ; global variable for default; = Round-Dimension-Down decimal places
    (cond
      ( (getint
          (strcat
            "\nNumber of decimal places &amp;lt;"
            (if _RDDdp_ (itoa _RDDdp_) "0"); prior value default if present, otherwise 0
            "&amp;gt;: "
          ); strcat
        ); getint
      ); User-input condition
      (_RDDdp_); prior value if present on Enter
      (0); default on Enter at first use
    ); cond
  ); setq
  (if (setq rddss (ssget '((0 . "DIMENSION"))))
    (repeat (setq n (sslength rddss)); then
      (setq dim (ssname rddss (setq n (1- n))))
      (if (not (wcmatch (cdr (assoc 100 (reverse (entget dim)))) "*Angular*"))
        (setpropertyvalue dim "DimensionText"
          (rtos (/ (fix (* (getpropertyvalue dim "Measurement") (expt 10 _RDDdp_))) (expt 10.0 _RDDdp_)) 2 _RDDdp_)
        ); setpropertyvalue
      ); if
    ); repeat
  ); if
); defun&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The default number of decimal places on first use is 0, but that can be changed if you have a typical standard.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you choose more than zero decimal places, whether trailing zeros appear depends on the DIMZIN System Variable.&amp;nbsp; If you want the trailing zeroes included, or not included, that can be set accordingly.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 13:58:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10584665#M56262</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2021-08-30T13:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding down dimension values</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10584756#M56263</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556"&gt;@hak_vz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;....&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;(defun round  (num places / neg ....
    (defun minusp (num) (cond ((numberp num) (&amp;lt; num 0.0))))
    (setq 
        neg (minusp num)
....
    (setq num (abs num)  _r (rem num 1.0) num (- num _r))
....
        (if neg (setq ret (strcat "-" ret)))
....&lt;/LI-CODE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;[All those elements are parts of the reason&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556"&gt;@hak_vz&lt;/a&gt;'s code is longer -- it uses a rounding function that is designed to handle &lt;EM&gt;negative numbers&lt;/EM&gt;, which simpler rounding functions often do not round correctly.&amp;nbsp; That's appropriate most of the time, but in Dimensions, the value you are rounding is &lt;EM&gt;never negative&lt;/EM&gt;, so there's no need to account for that.]&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 13:55:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10584756#M56263</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2021-08-30T13:55:46Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding down dimension values</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10586580#M56264</link>
      <description>&lt;P&gt;Thank you both very very much!!!! &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556"&gt;@hak_vz&lt;/a&gt;&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will finally use the solution by Kent Cooper (the third one), it works a bit better!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Aug 2021 06:51:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10586580#M56264</guid>
      <dc:creator>curro.aguilera</dc:creator>
      <dc:date>2021-08-31T06:51:25Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding down dimension values</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10602562#M56265</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt; , I'm having problems with the LISP when the measure is 0.10, 0.20, etc... The lisp is rounding down too! For example&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="curroaguilera_0-1630924775281.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/961742iD12731CA3E127DA3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="curroaguilera_0-1630924775281.png" alt="curroaguilera_0-1630924775281.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="curroaguilera_1-1630924832196.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/961743iBA4BCAEE10841E46/image-size/medium?v=v2&amp;amp;px=400" role="button" title="curroaguilera_1-1630924832196.png" alt="curroaguilera_1-1630924832196.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I would need to only round down dimensions with two decimals.&lt;/P&gt;&lt;P&gt;1.93-&amp;gt; 1.9&lt;/P&gt;&lt;P&gt;1.99-&amp;gt;1.9&lt;/P&gt;&lt;P&gt;1.90-&amp;gt;1.9&lt;/P&gt;&lt;P&gt;Please help!!&lt;/P&gt;&lt;P&gt;Thank you very much in advance!&lt;/P&gt;</description>
      <pubDate>Mon, 06 Sep 2021 10:48:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10602562#M56265</guid>
      <dc:creator>curro.aguilera</dc:creator>
      <dc:date>2021-09-06T10:48:52Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding down dimension values</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10602714#M56266</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/10888219"&gt;@curro.aguilera&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;.... when the measure is 0.10, 0.20, etc... The lisp is rounding down too! ....&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The only reason I can think of for it to do that is if those Measurement [Medidas] values are &lt;EM&gt;rounded up&lt;/EM&gt; to your four decimal places &lt;EM&gt;in display&lt;/EM&gt;, but their true values are slightly less, for example what your image says is 1.0000 is really something like 0.99973681.&amp;nbsp; Try changing the display precision in &lt;FONT face="arial,helvetica,sans-serif" color="#000000"&gt;UNITS&lt;/FONT&gt; to the maximum &lt;EM&gt;&lt;STRONG&gt;8&lt;/STRONG&gt;&lt;/EM&gt; decimal places, and see whether the Measurement value changes.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Sep 2021 11:46:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10602714#M56266</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2021-09-06T11:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding down dimension values</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10602742#M56267</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt; , thanks for posting again!&lt;/P&gt;&lt;P&gt;The point is, it's true there are a few dimensions that are 0.999997 as you said, but the lisp is rounding down too the dimensions that have exact values...&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="curroaguilera_0-1630929692504.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/961774i446CF319E39E8D8F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="curroaguilera_0-1630929692504.png" alt="curroaguilera_0-1630929692504.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Sep 2021 12:07:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10602742#M56267</guid>
      <dc:creator>curro.aguilera</dc:creator>
      <dc:date>2021-09-06T12:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding down dimension values</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10603393#M56268</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/10888219"&gt;@curro.aguilera&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;.... the lisp is rounding down too the dimensions that have exact values...&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;"Exact" even to 8 decimal places [the most AutoCAD will &lt;EM&gt;display&lt;/EM&gt;, but not as many as it knows] could still be rounded up.&amp;nbsp; Try this at the command line:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier" color="#000000"&gt;(rtos (cdr (assoc 42 (entget (car (entsel))))) 2 16)&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and select such a Dimension, to see it out to &lt;EM&gt;as many decimal places as AutoCAD can possibly know&lt;/EM&gt; about it.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Sep 2021 17:00:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10603393#M56268</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2021-09-06T17:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding down dimension values</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10604950#M56269</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt; , thanks again!&lt;/P&gt;&lt;P&gt;This is really weird. You are right, there are lines I drew with exact value (typing with the keyboard), and when I dimension that line, the value isn't exact. So I've added a simple tweak in the lisp you made:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(defun C:RDD ; = Round Dimension Down
  (/ rddss n dim)
  (initget 4); no negative
  (setq _RDDdp_ ; global variable for default; = Round-Dimension-Down decimal places
    (cond
      ( (getint
          (strcat
            "\nNumber of decimal places &amp;lt;"
            (if _RDDdp_ (itoa _RDDdp_) "0"); prior value default if present, otherwise 0
            "&amp;gt;: "
          ); strcat
        ); getint
      ); User-input condition
      (_RDDdp_); prior value if present on Enter
      (0); default on Enter at first use
    ); cond
  ); setq
  (if (setq rddss (ssget '((0 . "DIMENSION"))))
    (repeat (setq n (sslength rddss)); then
      (setq dim (ssname rddss (setq n (1- n))))
      (if (not (wcmatch (cdr (assoc 100 (reverse (entget dim)))) "*Angular*"))
        (setpropertyvalue dim "DimensionText"
          (rtos (/ (fix (* (+ (getpropertyvalue dim "Measurement") 0.001) (expt 10 _RDDdp_))) (expt 10.0 _RDDdp_)) 2 _RDDdp_)
        ); setpropertyvalue
      ); if
    ); repeat
  ); if
); defun&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just adding 0.001 to the measurement, the lisp now works nicely. It's not perfect but I think this will do the trick.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you come up with a better idea, I'll be really grateful!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much Kent!&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 09:41:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10604950#M56269</guid>
      <dc:creator>curro.aguilera</dc:creator>
      <dc:date>2021-09-07T09:41:40Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding down dimension values</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10608770#M56270</link>
      <description>&lt;P&gt;Hey,&amp;nbsp; Hak.&lt;/P&gt;
&lt;P&gt;Including proper disposition of DIMZIN, might this simple technique work?&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;;; Where str is the original number as a string...
(defun rounddown (str places)
  (rtos (/ (fix (* (expt 10 places)(read str)))(expt 10.0 places)) 2 places)
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Sep 2021 17:30:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10608770#M56270</guid>
      <dc:creator>john.uhden</dc:creator>
      <dc:date>2021-09-08T17:30:35Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding down dimension values</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10609141#M56271</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3930636"&gt;@john.uhden&lt;/a&gt;&amp;nbsp; At the moment I'm swamped with work. I have done tested your rounddown function and it seams it works . Good work!&lt;/P&gt;</description>
      <pubDate>Wed, 08 Sep 2021 20:05:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10609141#M56271</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2021-09-08T20:05:37Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding down dimension values</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10609274#M56272</link>
      <description>&lt;P&gt;That is operationally exactly like the end of the third routine in Message 10 &lt;EM&gt;except&lt;/EM&gt; for reading a string instead of pulling the Dimension's measured value.&amp;nbsp; So if the idea is that taking that value as a string will prevent the need to add a hair to the measured value to avoid rounding too far down, presumably the adjustment to that routine would be:&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;....
        (setpropertyvalue dim "DimensionText"
          (rtos
            (/
              (fix
                (*
                  (read (rtos (getpropertyvalue dim "Measurement") 2 (1+ _RDDdp_)))
                  (expt 10 _RDDdp_)
                 ); *
              ); fix
              (expt 10.0 _RDDdp_)
            ); /
            2
            _RDDdp_
          ); rtos
        ); setpropertyvalue
....
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Sep 2021 21:14:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-down-dimension-values/m-p/10609274#M56272</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2021-09-08T21:14:45Z</dc:date>
    </item>
  </channel>
</rss>

