123523058
发表于 2011-2-12 12:51:45
本帖最后由 Gu_xl 于 2011-2-12 13:22 编辑
;;花季20110212
http://hi.baidu.com/123523058/home
(defun C:XS ()
(XS)
)
(defun xs ()
(setq a (ssget '((0 . "TEXT"))))
(setq m (getint "输入小数位数: "))
(if a
(progn
(setq i 0)
(setq n (sslength a))
(while (< i n)
(setq e (ssname a i))
(setq eb (entget e))
(setq eb0 (cdr (assoc 1 eb)))
(setq eb0 (atof eb0))
(setq eb0 (rtos eb0 2 m))
(setq eb2 (str_xsws eb0 m))
(setq eb (subst (cons 1 eb2) (assoc 1 eb) eb))
(entmod eb)
(setq i (1+ i))
)
)
)
)
(defun str_xsws (str xsws / lst xs n bw)
(if (/= (vl-string-position (ascii ".") str) nil)
(progn (setq lst (HJ-read->biao str "."))
(setq xs (cadr lst))
(setq n (strlen xs))
(if (< n xsws)
(progn
(setq bw (- xsws n))
(repeat bw
(setq xs (strcat xs "0"))
)
)
)
(setq str (strcat (car lst) "." xs))
)
(if (/= xsws 0)
(progn
(setq str (strcat str "."))
(repeat xsws
(setq str (strcat str "0"))
)
)
)
)
str
)
(defun HJ-READ->BIAO (str fgf / biao s1 i)
(setq biao nil)
(setq i (vl-string-search fgf str))
(while i
(setq s1 (substr str 1 i))
(setq str (substr str (+ 2 i)))
(setq biao (append biao (list s1)))
(setq i (vl-string-search fgf str))
)
(append biao (list str))
)
Michael527
发表于 2011-2-12 19:22:00
dimzin的值是8的情况下,下面的代码写出的0.3的后面怎么有一堆0?
(setq pt (getpoint "\n写入点:"))
(setq w 0.3)
(setq w (atof (rtos w 2 2)))
(command ".text" "m" pt "" 0 w )
ZZXXQQ
发表于 2011-2-12 20:33:54
帮助里不是说了只对rtos有效。你用atof就无效了。
Michael527
发表于 2011-2-12 22:35:12
ZZXXQQ 发表于 2011-2-12 20:33 static/image/common/back.gif
帮助里不是说了只对rtos有效。你用atof就无效了。
谢谢,一直没往这方面想啊
461045462
发表于 2011-2-14 07:33:45
谢谢123523058 与Gu_xl ,11楼的程序收藏了,学到了新的定小数位方式。
prcstone
发表于 2011-2-16 11:28:59
学习了,呵呵
dafeilang
发表于 2011-4-13 23:31:14
好东西 收藏了
yan19851204
发表于 2011-6-4 16:22:35
(defun C:XS ()
(XS)
)
(defun xs ()
(setq a (ssget '((0 . "TEXT"))))
(setq m (getint "输入小数位数: "))
(if a
(progn
(setq i 0)
(setq n (sslength a))
(while (< i n)
(setq e (ssname a i))
(setq eb (entget e))
(setq eb0 (cdr (assoc 1 eb)))
(setq eb0 (atof eb0))
(setq eb0 (rtos eb0 2 m))
(setq eb2 (str_xsws eb0 m))
(setq eb (subst (cons 1 eb2) (assoc 1 eb) eb))
(entmod eb)
(setq i (1+ i))
)
)
)
)
(defun str_xsws (str xsws / lst xs n bw)
(if (/= (vl-string-position (ascii ".") str) nil)
(progn (setq lst (HJ-read->biao str "."))
(setq xs (cadr lst))
(setq n (strlen xs))
(if (< n xsws)
(progn
(setq bw (- xsws n))
(repeat bw
(setq xs (strcat xs "0"))
)
)
)
(setq str (strcat (car lst) "." xs))
)
(if (/= xsws 0)
(progn
(setq str (strcat str "."))
(repeat xsws
(setq str (strcat str "0"))
)
)
)
)
str
)
(defun HJ-READ->BIAO (str fgf / biao s1 i)
(setq biao nil)
(setq i (vl-string-search fgf str))
(while i
(setq s1 (substr str 1 i))
(setq str (substr str (+ 2 i)))
(setq biao (append biao (list s1)))
(setq i (vl-string-search fgf str))
)
(append biao (list str))
)
coco25825
发表于 2011-7-1 20:52:38
有没有批量把2400改为2.4的命令
fire9527
发表于 2013-1-8 20:38:39
Gu_xl 发表于 2011-2-11 12:25 static/image/common/back.gif
回复 461045462 的帖子
G版,程序怎么不提示选择,而把所有数字小数位数都变了呢?