3dwannab Posted February 1, 2022 Posted February 1, 2022 (edited) I hope this make sense. I was to select some text with (setq ssRemove (ssget '((0 . "*TEXT")))) Then have a another selection set that has text, leaders, multileaders and dimensions. (setq ssKeep (ssget "_X" '((0 . "*TEXT,LEADER,MULTILEADER,DIMENSION")))) Then remove all but the selected text in the fist part there. Here's what I've come up with and I was wondering if this would a good way or would there be better or faster methods than this? ;; 3dwannab ;; Removes a selection set from another but retains the items from the first. ;; Returns a new selection set. ;; Wrote on 2022.01.31 ;; Usage: ;; (setq ssNew (3d:RemoveSSFromSS ssRemove ssKeep)) (defun 3d:RemoveSSFromSS ( ssKeep ssRemove / i ent ssNew ) (setq ssNew (ssadd)) (repeat (setq i (sslength ssRemove)) (setq ent (ssname ssRemove (setq i (1- i)))) ;; Just don't add the entity from the first selection (if (not (ssmemb ent ssKeep)) (setq ssNew (ssadd ent ssNew)) ) ) ssNew ) (setq ssRemove (ssget '((0 . "*TEXT")))) (setq ssKeep (ssget "_X" '((0 . "*TEXT,LEADER,MULTILEADER,DIMENSION")))) (setq ssNew (3d:RemoveSSFromSS ssRemove ssKeep)) (sssetfirst nil ssNew) (princ) Here's what it does. It's like an inverse selection of sorts. Edited February 1, 2022 by 3dwannab Quote
mhupp Posted February 1, 2022 Posted February 1, 2022 (edited) Wrote this to invert the selection of things on screen ;;----------------------------------------------------------------------------;; ;; Invert Selection on Screen (defun C:SEE (/ SS SS1) (if (setq SS (cond ((ssget "_I")) ; preselection, if any ((ssget)) ; User selection if no pre-selection ) ) (progn (if (setq SS1 (ssget "_WP" (GetScreenCoords))) (progn (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) (ssdel ent SS1) ) (sssetfirst nil SS1) ) (prompt "\nNothing on Screen Zoom Out") ) ) ) (princ) ) ;Calculates View Window (defun GetScreenCoords (/ ViwCen ViwDim ViwSiz VptMin VptMax) (setq ViwSiz (/ (getvar "VIEWSIZE") 2) ViwCen (getvar "VIEWCTR") ViwDim (list (* ViwSiz (apply '/ (getvar "SCREENSIZE"))) ViwSiz) VptMin (mapcar '- ViwCen ViwDim) VptMax (mapcar '+ ViwCen ViwDim) ) (list VptMin VptMax) ) Edited February 1, 2022 by mhupp princ / code update 1 Quote
3dwannab Posted February 1, 2022 Author Posted February 1, 2022 Nice but it returns Select objects: ; error: bad argument type: lselsetp nil Quote
mhupp Posted February 1, 2022 Posted February 1, 2022 (edited) It was just an example of how to remove things from a selection set. You have to select something during the command or have something selected then run the command. It will take the inverse of whats completely on screen. Repeat the command to switch back and forth. will also error if nothing is on the screen. To directly answer you question. the foreach with ssdel from my example is a better option on how to remove one selection set from another. also you don't have to build a 3rd selection set (setq ssRemove (ssget '((0 . "*TEXT")))) (setq ssKeep (ssget "_X" '((0 . "*TEXT,LEADER,MULTILEADER,DIMENSION")))) (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ssRemove))) (ssdel ent ssKeep) ;only removes the entity from the selection set doesn't delete the entity from the drawing. ) (sssetfirst nil ssKeep) (princ) Edited February 1, 2022 by mhupp 1 Quote
ronjonp Posted February 4, 2022 Posted February 4, 2022 Here's another thought to exclude a picked item type: (defun c:foo (/ a e f s) (cond ((setq e (car (entsel "\nPick something to exclude: "))) (setq f "*TEXT,LEADER,MULTILEADER,DIMENSION") (setq a (cdr (assoc 0 (entget e)))) (sssetfirst nil (ssget "_A" (list (cons 0 (if (wcmatch a "*TEXT") (vl-string-subst "~*TEXT" "*TEXT" f) (vl-string-subst (strcat "~" a) a f) ) ) ) ) ) ) ) (princ) ) 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.