这是网上找到的一个Lisp代码,这是实现CAD某种功能的插件,但根据此代码所选择出来的对象无法进行下一步的编辑,或者无法承接下一个操作命令,即回车(空格)确认命令后,所选对象变为“未选择状态”,不知道是不是该代码缺少某种函数?求大神完善该代码
以下为代码内容:
;Polyline/circle select - http://www.xanadu.cz - http://www.cadforum.cz
;(use the WPS command or 'WPS inside an object selection prompt)
(defun C:WPS ( / i elist at cmde cen rad p1)
(setq cmde (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq i 0 elist (entget (car (entsel "\nPick a circle or polyline: "))))
(setvar "OSMODE" (boole 7 (getvar "OSMODE") 16384))
(if (zerop (getvar "CMDACTIVE")) (command "_select"))
(command "_wp") ; or _CP
(if (= (cdr(assoc 0 elist)) "CIRCLE")
(progn
(setq cen (cdr (assoc 10 elist))
rad (cdr (assoc 40 elist))
)
(repeat 90 ; 360/4 0.06981317=4*pi/180
(setq p1 (polar cen (* i 0.06981317) rad) i (1+ i))
; (command "_POINT" (trans p1 0 1))
(command (trans p1 0 1))
)); else
(repeat (length elist)
(setq at (nth i elist) i (1+ i))
; (if (= (car at) 10) (command (cdr at)))
(if (= (car at) 10) (command (trans (cdr at) 0 1)))
)
);if CIRCLE
(command "")
(setvar "OSMODE" (boole 2 (getvar "OSMODE") 16384))
(setvar "cmdecho" cmde)
(princ)
)
以下为代码内容:
;Polyline/circle select - http://www.xanadu.cz - http://www.cadforum.cz
;(use the WPS command or 'WPS inside an object selection prompt)
(defun C:WPS ( / i elist at cmde cen rad p1)
(setq cmde (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq i 0 elist (entget (car (entsel "\nPick a circle or polyline: "))))
(setvar "OSMODE" (boole 7 (getvar "OSMODE") 16384))
(if (zerop (getvar "CMDACTIVE")) (command "_select"))
(command "_wp") ; or _CP
(if (= (cdr(assoc 0 elist)) "CIRCLE")
(progn
(setq cen (cdr (assoc 10 elist))
rad (cdr (assoc 40 elist))
)
(repeat 90 ; 360/4 0.06981317=4*pi/180
(setq p1 (polar cen (* i 0.06981317) rad) i (1+ i))
; (command "_POINT" (trans p1 0 1))
(command (trans p1 0 1))
)); else
(repeat (length elist)
(setq at (nth i elist) i (1+ i))
; (if (= (car at) 10) (command (cdr at)))
(if (= (car at) 10) (command (trans (cdr at) 0 1)))
)
);if CIRCLE
(command "")
(setvar "OSMODE" (boole 2 (getvar "OSMODE") 16384))
(setvar "cmdecho" cmde)
(princ)
)