TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: KewlToyZ on October 23, 2008, 01:50:27 PM
-
(setq x 17.5)
(setq fmtval (rtos x 4 2)) ; Mode 4 = architectural
(princ (strcat str fmtval)) ; displays Value formatted as 1'-5 1/2"
(setvar "unitmode" 0)
(setvar "LUPREC" 0)
(setvar "DIMRND" 1)
(setvar "DIMDEC" 0)
How do I get rtos to round to the nearest foot for output?
Is this a variable I am missing?
-
Use Kerrys function
;;* kdub:roundNearest (numVal roundTo Mode displayPrecision)
;; Round a numeric positive number to the NEAREST 'rounded' number
;; and format to n digits
;; kwb@theSwamp 20070814
;; 20081023 CAB added Mode
(DEFUN kdub:roundNearest (numVal roundTo Mode displayPrecision / remNum)
(SETQ remNum (REM numVal roundTo))
(RTOS (IF (>= (* 2 remNum) roundTo)
(+ numVal (- roundTo remNum))
(- numVal remNum)
)
Mode
displayPrecision
)
)
(kdub:roundNearest 17.5 12 4 0)
"1'-0\""
-
Thanks CAB 8-)
-
Glad to help & thanks to Kerry. 8-)
http://www.theswamp.org/index.php?topic=18695.0
-
Nice adaptation Alan .. I tend to ignore that some of the world still uses inches and feet. ( though I still thing in both occasionally for non technical stuff ... :) )
-
All of My World uses feet & inched. 8-)
-
I ended up adapting it differently for the setup I was doing using the files attached.
Mainly I was trying to make something generic for creating engineering spaces.
When I get time I was thinking of adding a block insert to create a small Engineering Space numeric bubble and a routine at the end to autoincrement the attribute tag so notes can be assigned.
Its still a pretty hokey adaption of what the guys on the swamp here made but it works. :wink: