出错,求帮助。管道用已知2点,求2点距离,坡度,并标注在图纸上,
(defun c:YS1 ()(setvar "CMDECHO" 0)
(if (and
(setq pt1 (getpoint "\nFirst Point 点一 :"))
(setq pt2 (getpoint pt1 "\nSecond Point 点二 :"))
)
(progn
(setq xx (- (car pt2) (car pt1))
yy (- (cadr pt2) (cadr pt1))
num (/ yy 1.0 xx)
str (rtos (* 100 num) 2 1)
)
(setq dst (distance pt1 pt2)
str1 (rtos (dst 2 1))
dtt (strcat "DN300 L="str1 "m i="str "%")
a1 (angle pt1 pt2)
a2 (* (/ a1 pi) 180)
ptt (polar pt1 a1 (/ dst 2))
))
(command "text" "j" "bc" ptt 2.5 a2 dtt)
)
(princ)
)
求高手帮我看看
本帖最后由 vectra 于 2013-7-16 17:00 编辑
(defun c:ys1 ()
(setvar "CMDECHO" 0)
(if (and
(setq pt1 (getpoint "\nFirst Point ?? :"))
(setq pt2 (getpoint pt1 "\nSecond Point ?? :"))
)
(progn
(setq xx (- (car pt2) (car pt1))
yy (- (cadr pt2) (cadr pt1))
num (/ yy 1.0 xx)
str (rtos (* 100 num) 2 1)
)
(setq dst (distance pt1 pt2)
str1 (rtos dst 2 1) ;; FIX 1
dtt (strcat "DN300 L=" str1 "m i=" str "%")
a1 (angle pt1 pt2)
a2 (* (/ a1 pi) 180)
ptt (polar pt1 a1 (/ dst 2))
)
(command "text" "j" "bc" ptt 2.5 a2 dtt) ;; FIX2
)
)
(princ)
)
FIX1 多余的括号删除
FIX2 command放置的位置有误
首先声明一下,我不是高手。现将程序修改如下:
(defun c:YS1 ()
(setvar "CMDECHO" 0)
(if (and
(setq pt1 (getpoint "\nFirst Point 点一 :"))
(setq pt2 (getpoint pt1 "\nSecond Point 点二 :"))
)
(progn
(setq xx (- (car pt2) (car pt1))
yy (- (cadr pt2) (cadr pt1))
num (/ yy 1.0 xx)
str (rtos (* 100 num) 2 1)
)
(setq dst (distance pt1 pt2)
str1 (rtos dst 2 1)
dtt (strcat "DN300 L="str1 "m i="str "%")
a1 (angle pt1 pt2)
a2 (* (/ a1 pi) 180)
ptt (polar pt1 a1 (/ dst 2))
)
(command "text" "j" "bc" ptt 2.5 a2 dtt)
)
)
(princ)
) 楼上两位正解 谢谢各位大哥热心帮忙 呵呵,想不到我也才参与过呀 vectra 发表于 2013-7-16 16:58
FIX1 多余的括号删除
FIX2 command放置的位置有误
前辈好,请问能不能实现动态确定文字标注位置
页:
[1]