达人看看这个LISP哪有问题
;---------------------------(defun C:Bxh (/ p1 p2 p3 1 ang 1 bx bxh radi txth) ;标序号
(setq radi 5) ;圆圈半径
(setq txth 5) ;字高
(if (not bx) (setq bx 1))
(setq p1 (getpoint "\n请选择起点:")) ;在零件上选一点
(setq p2 (getpoint "\n请选择第二点或回车表示无第二点")) ;标注位置处一点
(setq bxh (getint (gstr "\n请输入序号" bx))) ;序号数
(if bxh (setq bx bxh))
(cond (p2
(command "layer" "set" 2 " ") ;改到画细线图层
(setq ang 1 (angle p1 p2))
(setq p3 (polar p1 ang (-(distance p1 p2) radi))) ;画圆、线
(command "pline"
(polar p1 ang 1 0.25)
"w" 0.5 0,5 "A" "CE"p1"A"359.9"L""W"0 0 p3"")
(command"circle"p2 radi)
(command "layer" "set" 6 " " ;改到写文字图层
"text" "J" "M" p2 txth 0 bx) ;写文字
)
((not p2) ;如果在零件中直接标注
(command "layer" "set" 2 " ") ;改到画细线图层
(Command "circle" p1 radi) ;画圆
(command "layer" "set" 6 " " ;改到写文字图层
"text" "J" "M" p1 txth 0 bx) ;写文字
)
)
(setq bx (+ bx 1))
(princ)
)
;----------------------- 粗略的看了一下,太困了,没想进去,有空再来给你瞧瞧
回复 #2 yrgui 的帖子
多谢达人光顾,还请清醒后多多指教 根据原程序的思路,我改好了:;;;该程序用于给图标序号
;;;两种方式:有引线和无引线
;;;使用该程序时需确保图中设有细线和文字两个图层
(defun c:bxh (/ p0 p1 p2 p3 ang bx bxh radi txth)
(graphscr)
(setvar "cmdecho" 0)
;;默认值
(setq radi 5
txth 5
bx 1
p1 (getpoint "\n请选择起点:")
)
;;循环标多个
(while p1
(setq p2 (getpoint p1 "\n请选择第二点或回车表示无第二点")
bxh (getint (strcat "\n请输入序号<" (rtos bx) ">: "))
)
(if bxh (setq bx bxh))
(if p2
;;引出线标注
(progn
(command "layer" "set" "细线" "") ;改到画细线图层
(setq p0 (polar p1 (angle p1 p2) 0.25)
p3 (polar p2 (angle p2 p1) radi)
)
(command "pline" p0 "w" 0.5 0.5 "A" "CE" p1 "A" 359.9 "L" "W" 0 0 p3 "");画引出线
(command "circle" p2 radi);画圆
(command "layer" "set" "文字" "") ;改到写文字图层
(command "text" "J" "M" p2 txth 0 bx) ;写文字
)
;;原处直接标注
(progn
(command "layer" "set" "细线" "") ;改到画细线图层
(command "circle" p1 radi) ;画圆
(command "layer" "set" "文字" "") ;改到写文字图层
(command "text" "J" "M" p1 txth 0 bx) ;写文字
)
)
(setq bx (+ bx 1);标号自动增加
p1 (getpoint "\n下一处的起点<结束>: ")
)
);结束循环
(setvar "cmdecho" 1)
(princ)
)
原帖由 yrgui 于 2008-8-25 08:09 发表 http://www.askcad.com/bbs/images/common/back.gif
根据原程序的思路,我改好了:
;;;该程序用于给图标序号
;;;两种方式:有引线和无引线
;;;使用该程序时需确保图中设有细线和文字两个图层
(defun c:bxh (/ p0 p1 p2 p3 ang bx bxh radi txth)
...
这个问题如何解决,如图所示,线穿过圆了 原帖由 yrgui 于 2008-8-25 08:09 发表 http://www.askcad.com/bbs/images/common/back.gif
根据原程序的思路,我改好了:
;;;该程序用于给图标序号
;;;两种方式:有引线和无引线
;;;使用该程序时需确保图中设有细线和文字两个图层
(defun c:bxh (/ p0 p1 p2 p3 ang bx bxh radi txth)
...
还有一问?你标注时的橡皮筋是怎么实现的? ----p3 (polar p2 (angle p2 p1) radi)
)
(command "pline" p0 "w" 0.5 0.5 "A" "CE" p1 "A" 359.9 "L" "W" 0 0 p3 "") ;画引出线
p3不是圆心啊,我也试过,也出过类似情况,应该不是每个都穿过去吧,我再检查检查
(setq p2 (getpoint p1 "\n请选择第二点或回车表示无第二点")
getpoint函数后面加点 p1 就会使点选 p2 时出橡皮筋 原帖由 yrgui 于 2008-8-26 14:06 发表 http://www.askcad.com/bbs/images/common/back.gif
----p3 (polar p2 (angle p2 p1) radi)
)
(command "pline" p0 "w" 0.5 0.5 "A" "CE" p1 "A" 359.9 "L" "W" 0 0 p3 "") ;画引出线
p3不是圆心啊,我也试过,也出过类似情况,应该不是每个都穿过去吧, ...
多谢指点,好让人高兴的橡皮筋啊:lol
(setvar "aperture" 1);控制靶框大小
加上这一句后,“穿心”情况偶有出现,不过,不完美啊:L
获取当前系统变量
设置系统变量
恢复系统变量
如:
(setq v1 (getvar "osmode"));获取目标捕捉初始状态,将其赋给变量v1
(setvar "osmode" 0);设置目标捕捉状态为无
(setvar "osmode" v1);恢复目标捕捉初始状态
上面这不知道你用过不,彼此携手共进啊:lol
(while p1 ;以p1是否为空作为条件?
(if bxh (setq bx bxh));这句压根没看明白:L
(if p2 ;以p1是否为空作为条件?
烦请解析下
页:
[1]