回复 cxs259 的帖子
楼上的都别废话,用这个吧!
- (defun C:DUPREM (/ F1 SLE SA CA TA LA LB ENTA EA TYPA A1 A2 A3 A4 SC
- LTEST TES
- )
- (setq F1 NIL
- F1 0
- )
- (or :GCHOICE (setq :GCHOICE "Set"))
- (initget "Set Limits All")
- (setq SLE
- (getkword (strcat "\n选择集类型 [Set/Limits/All] <"
- :GCHOICE
- ">: "
- )
- )
- )
- (if (not SLE)
- (setq SLE :GCHOICE)
- (setq :GCHOICE SLE)
- )
- (cond
- ((= SLE "Set") (setq SA (ssget)))
- ((= SLE "Limits")
- (setq SA (ssget "c" (getvar "extmin") (getvar "extmax")))
- )
- ((= SLE "All") (setq SA (ssget "X")))
- )
- (if (and SA (= (type SA) 'PICKSET) (not (zerop (sslength SA))))
- (progn
- (setq CA 0
- TA (sslength SA)
- LA NIL
- LB NIL
- )
- (while (< CA TA)
- (setq ENTA (ssname SA CA)
- EA (cdr (entget ENTA))
- TYPA (cdr (assoc 0 EA))
- )
- (setq A1 (assoc 5 EA))
- (setq A2 (cons 5 ""))
- (setq EA (subst A2 A1 EA))
- (if (wcmatch (getvar "ACADVER") "*15*")
- (progn
- (setq A3 (assoc 330 EA))
- (setq A4 (cons 330 ""))
- (setq EA (subst A4 A3 EA))
- )
- )
- (setq LA (cons ENTA LA)
- LB (cons EA LB)
- CA (+ CA 1)
- )
- )
- (setq SC NIL
- SC (ssadd)
- LTEST LB
- )
- (setq CA 0)
- (setq TES (car LTEST)
- LTEST (cdr LTEST)
- TA NIL
- TA (length LTEST)
- )
- (while (/= TA 0)
- (if (member TES LTEST)
- (progn
- (setq SC (ssadd (nth CA LA) SC))
- (setq F1 (+ F1 1))
- )
- )
- (setq CA (+ CA 1))
- (setq TES (car LTEST)
- LTEST (cdr LTEST)
- TA (length LTEST)
- )
- )
- (command "erase" SC "")
- (redraw)
- (prompt "\n")
- (prin1 F1)
- (prompt " 个物体被删除.")
- )
- )
- (princ)
- )
|