文字加圈,出错了!循环不了。。。求助!
(defun C:JQ()(setvar "cmdecho" 0)
(setq dd (getdist "\n 输入字间与圆周距离<2>: "))
(if (null dd) (setq dd 2.0))
(setq ss (ssget))
(setq i 0)
(repeat (sslength ss)
(setq ssn (ssname ss i))
(setq ssdata (entget ssn))
(setq sstyp (cdr (assoc 0 ssdata)))
(if (= sstyp "TEXT")
(progn
(command "ucs" "e" ssn)
(setq box (textbox ssdata)) ;取得文字外框坐标
(setq p1 (car box))
(setq p3 (cadr box))
(setq p2 (list (car p3) (cadr p1)))
(setq p4 (list (car p1) (cadr p3)))
(setq dda (+ (/ (distance p1 p2) 2) dd))
(setq cen (inters p1 p3 p2 p4))
(command "circle" cen dda)
)
)
(setq i (1+i))
)
(command "ucs" "")
(prin1)
)
;;;;;
; 错误: no function definition: 1+I
本帖最后由 琴剑江山_10184 于 2015-11-29 20:22 编辑
(defun C:JQ (/ A B DD EN ENT LEN OS P1 P2 PL PP SS)
(setvar "cmdecho" 0)
(setq os (getvar 'osmode))
(setvar 'osmode 0)
(setq dd (getdist "\n 输入字间与圆周距离<2>: "))
(if (null dd)
(setq dd 2.0)
)
(setqss(ssget '((0 . "TEXT")))
Len (sslength ss)
)
(repeat Len
(setq en (ssname ss (setq Len (1- Len))))
(vl-cmdf "ucs" "OB" en)
(setq ent (entget en)
pp(textbox ent)
p1(car pp)
p2(cadr pp)
pL(mapcar '(lambda (a b) (/ (+ a b) 2)) p1 p2)
dr(+ (/ (distance p1 p2) 2) dd)
)
(command "circle" pL dr)
)
(vl-cmdf "ucs" "W")
(setvar 'osmode os)
(prin1)
)
yaoyang1018 发表于 2016-6-24 15:33
确定字高后选出字中心点以字高的1.25倍画圈不就好了,我写过一个到现在还在用呢.而且无论多少数字都可以搞定 ...
能分享一下吗 根据提示找到1+i你就知道为什么出错了 llsheng_73 发表于 2015-11-29 12:27 static/image/common/back.gif
根据提示找到1+i你就知道为什么出错了
谢谢LLsheng 大师 llsheng_73 发表于 2015-11-29 12:27 static/image/common/back.gif
根据提示找到1+i你就知道为什么出错了
大神,为什么出来是前者,而不是后者效果么?
本帖最后由 434939575 于 2015-11-29 18:29 编辑
(defun C:tt()
(setvar "cmdecho" 0)
(setq dd (getdist "\n 输入字间与圆周距离<2>: "))
;
(if (null dd) (setq dd 2.0)dd)
(setq ss (ssget))
(setq i 0)
(repeat (sslength ss)
(setq ssn (ssname ss i))
(setq ssdata (entget ssn))
(setq text_hei (cdr(assoc 40 ssdata)))
(setq sstyp (cdr (assoc 0 ssdata)))
(if (= sstyp "TEXT")
(progn
(command "ucs" "e" ssn)
(setq box (textbox ssdata)) ;取得文字外框坐标
(setq p1 (car box))
(setq p3 (cadr box))
(setq p2 (list (car p3) (cadr p1)))
(setq p4 (list (car p1) (cadr p3)))
(setq dda (+ (/ (distance p1 p2) 2) dd))
(setq cen (inters p1 p3 p2 p4))
(command "circle" cen (+ dd(* 0.5 text_hei)))
)
)
(setq i (1+ i))
)
(command "ucs" "")
(prin1)
)
434939575 发表于 2015-11-29 18:23 static/image/common/back.gif
谢谢兄弟回复,但是还有点不如意 434939575 发表于 2015-11-29 18:23 static/image/common/back.gif
能否再看看。。。
这个也有问题了,第一圈的点不对,不删除此圈,第二个就是对的了 (defun C:tt()
(setvar "cmdecho" 0)
(setq dd (getdist "\n 输入字间与圆周距离<2>: "))
;
(if (null dd) (setq dd 2.0)dd)
(setq ss (ssget))
(setq i 0)
(repeat (sslength ss)
(setq ssn (ssname ss i))
(setq ssdata (entget ssn))
(setq text_hei (cdr(assoc 40 ssdata)))
(setq sstyp (cdr (assoc 0 ssdata)))
(if (= sstyp "TEXT")
(progn
(command "ucs" "e" ssn)
(setq box (textbox ssdata)) ;取得文字外框坐标
(setq p1 (car box))
(setq p3 (cadr box))
(setq dis(/(distance p1 p3)2))
(setq p2 (list (car p3) (cadr p1)))
(setq p4 (list (car p1) (cadr p3)))
(setq dda (+ (/ (distance p1 p2) 2) dd))
(setq cen (inters p1 p3 p2 p4))
(command "circle" cen (+ dd dis))
)
)
(setq i (1+ i))
)
(command "ucs" "")
(prin1)
) 434939575 发表于 2015-11-29 19:39 static/image/common/back.gif
还是不行呢,这个代码是以插入点(对齐点)为圆心画圆的。奇怪了。。。