TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: MSTG007 on January 18, 2017, 11:56:04 AM
-
I do not know if I did something awhile ago to get this not work... (I am good at that). But I am having some rounding issues. The routine is suppose to override the dim text from <> to (X SPACES @ X' = <>').
For example if the dim is 63'. The label now shows it to be 6 Spaces @ 9'. 6x9=54.
But in the same drawing on a different dimension. The dim is 162'. The Label shows 18 Spaces @ 9' = 162'. Which is right.
The Routine is within a macro.
^C^C-dimstyle;V;L80;DIMZIN;8;-dimstyle;apply;all;;(load "SPCT");SPCT;
Any ideas?
(defun C:SPCT
(/ ename obj dim div total fract)
(setq ename (car (entsel "\nSelect dimension: ")))
(setq obj (vlax-ename->vla-object ename))
(setq dim (vla-get-measurement obj))
(if (not def)
(setq def 1))
(setq div (getdist (strcat "\nDivide into <" (rtos def) ">: ")))
(if (not div)
(setq div def)
(setq def div))
(setq total (/ dim div))
(setq fract (- total (fix total)))
(vla-put-textoverride
obj
(strcat (itoa (fix total))
" SPACES @ "
(rtos div)
"'"
" = <>"
))
(princ))
Thanks for the help!
-
Are you sure your dimension is exactly 63'? (setq total (fix (/ 62.999999 9))) = 6
-
I would suggest changing all occurrences of:
(fix total)
to:
(fix (+ 1e-8 total))
-
Ron and Lee,
Thanks for the pointers. That's what it was missing. Thank you guys again!