PDA

View Full Version : Selection set substraction



am4soft
2009-11-22, 05:19 PM
Is there an easy way to substract one selection set from another? For example, I have a selection set of all lines on layer zero. I have another selection set of lines on layer zero that pass through certain points. How can I substract the second set from the first using autolisp?
Thanks,
TDD

alanjt
2009-11-22, 05:36 PM
Step through the selection set, and check each ename with ssmemb, if T, then ssdel the ename from the selectoin set.

hofcad
2009-11-25, 08:07 AM
(defun ssdiff (ss1 ss2 / ~hl ss3)
(setq ~hl (getvar "HIGHLIGHT"))
(setvar "HIGHLIGHT" 0)
(command "_.SELECT" ss1 "_R" ss2 "")
(setq ss3 (ssget "P"))
(setvar "HIGHLIGHT" ~hl)
ss3
)

Regards, HofCAD CSI.

alanjt
2009-11-25, 07:43 PM
;;; Subtract matching enames from selection set
;;; ss1 - Selection set to evaluate
;;; ss2 - Selection set to compare with
;;; Alan J. Thompson, 11.25.09
(defun AT:SSRemove (ss1 ss2 / ss3 n)
(setq n -1
ss3 ss1
) ;_ setq
(repeat (sslength ss2)
(if (ssmemb (setq o (ssname ss2 (setq n (1+ n))))
ss3
) ;_ ssmemb
(ssdel o ss3)
) ;_ if
) ;_ repeat
ss3
) ;_ defun