关于CAD lisp的,怎么能让它框选,和多选。

大哥帮忙改下,我想让它能够框选、多选,不然一条一条选太没效率了
源码如下:
(defun c:ppp( / pet ss)
(setq pet (getvar "PEDITACCEPT"))
(setvar "PEDITACCEPT" 1)
(while (setq ss (ssget '((0 . "ARC,*LINE"))))
(command "_pedit" (ssname ss 0) "j" ss "" ""))
(setvar "PEDITACCEPT" pet)
(princ))
拜托了,让它能多选!!!一次选择几十条直线同时变为多段线

第1个回答  2012-05-07
可以用反应器实现,前提是画线和输入文字必须用定义的函数一次性操作完成.LISP代码如下:
(VL-Load-Com)
(defun c:Line_Txt(/ Pt Pt1 Pt2 EntLine HandTxt VlaObj Tmp)
(setq Pt1 (getpoint "\n指定第一点:"))
(setq Pt2 (getpoint "\n指定下一点:"))
(setq Pt (list (/ (+ (car Pt1) (car Pt2)) 2) (/ (+ (cadr Pt1) (cadr Pt2)) 2) (/ (+ (caddr Pt1) (caddr Pt2)) 2)))
(command "._Line" Pt1 Pt2 "")
(setq EntLine (entlast))
(setq VlaObj (cons (VLAX-EName->VLA-Object EntLine) '()));;将直线转换为VLA对象

(setq HandTxt '((0 . "TEXT"))
HandTxt (append HandTxt (list (append '(10) Pt1)))
HandTxt (append HandTxt (list (append '(11) Pt)))
HandTxt (append HandTxt (list (cons 40 (getdist "\n指定高度:"))))
HandTxt (append HandTxt (list (cons 72 1)))
HandTxt (append HandTxt (list (cons 73 0)))
HandTxt (append HandTxt (list (cons 50 (angle pt1 Pt2))))
HandTxt (append HandTxt (list (cons 1 (getstring "\n输入文字:>")))))
(entmake HandTxt)
(setq HandTxt (cdr (Assoc 5 (entget (entlast)))))
(VLR-Pers (VLR-Object-Reactor vlaObj HandTxt '((:vlr-modified . LineModefy))))
)

(defun LineModefy(EntLine EntTxt parameter-list / Pt Pt1 Pt2)
(setq EntTxt (entget (HandEnt (VLR-Data EntTxt))))
(setq EntLine (entget (VLAX-VLA-Object->EName EntLine)))
(setq Pt1 (cdr (assoc 10 EntLine)) Pt2 (cdr (assoc 11 EntLine)))
(setq Pt (list (/ (+ (car Pt1) (car Pt2)) 2) (/ (+ (cadr Pt1) (cadr Pt2)) 2) (/ (+ (caddr Pt1) (caddr Pt2)) 2)))
(setq EntTxt (subst (cons 50 (angle Pt1 Pt2)) (assoc 50 EntTxt) EntTxt)
EntTxt (subst (append '(10) Pt1) (assoc 10 EntTxt) EntTxt)
EntTxt (subst (append '(11) Pt) (assoc 11 EntTxt) EntTxt))
(entmod EntTxt)
)

也可以用属性块实现,将文字与直线定义成属性块,打开块编辑器,在参数选项板中设定点参数和旋转参数,在动作选项板中定义要执行的动作,……,具体的自己参照属性块的做吧。追问

放屁

第2个回答  2012-05-10
(setq ss (ssget '((0 . "ARC,*LINE"))))
(setq n (sslength ss) i 0)
(while (< i n)
(command "_pedit" (ssname ss i) "j" ss "" ""))
(setq i (+ i 1))
......)
这样试试吧,我没有调试,算法应该不错。本回答被提问者采纳
相似回答