Sambo Posted November 28, 2022 Posted November 28, 2022 (edited) Hi guys, Is there a way to create a selection set that's a filter of an existing selection set without using ssget "_P"? My current code is below. I'm just wanting to filter ss1 directly as filtering through ssget "_P" is causing an issue where its dropping some entities when running the script in it's entirety, but doing exactly what I want when I run the code line by line. (sssetfirst nil (selectinside CURRENTPOLY)) ;;;;;; Creates a selection set ss1 (setq ALLENTS (ssget "_P" (list (cons -4 "<AND") (cons -4 "<OR") (cons 0 "TEXT") (cons 0 "MTEXT") (cons -4 "OR>") (cons -4 "<OR") (cons 8 "TEXT_STAGE NUMBER_LISP") (cons 8 "TEXT_LOT NUMBER_LISP") (cons 8 "POLY*") (cons -4 "OR>") (cons -4 "AND>") ) ) ) Edited November 28, 2022 by Sambo Quote
BIGAL Posted November 28, 2022 Posted November 28, 2022 You may have to loop through the selection set using a if with ands. Not tested very much (setq ALLENTS (ssadd)) (repeat (setq x (sslength ss1)) (setq ent (ssname ss1 (setq x (1- x)))) (setq entgt (entget ent)) (setq str (cdr (assoc 0 entgt))) (setq lay (cdr (assoc 8 entgt))) (if (and (or (= str "TEXT")(= str "MTEXT")) (or (= lay "TEXT_STAGE NUMBER_LISP")(= lay "TEXT_LOT NUMBER_LISP")(wcmatch "POLY" "*POLY*")) ) (setq allents (ssadd ent allents)) ) ) 1 Quote
Sambo Posted November 28, 2022 Author Posted November 28, 2022 Thanks mate, that code worked perfectly. Turns out the reason it wasn't running properly though was because we had the exact same function in another lisp that was using an outdated method to pick the objects in our selection set that was buggy. So when we thought we were running the function inside the lisp we were working on we were actually running it from another lisp. Quote
ronjonp Posted November 28, 2022 Posted November 28, 2022 @Sambo FWIW ;; This (setq allents (ssget "_P" (list (cons -4 "<AND") (cons -4 "<OR") (cons 0 "TEXT") (cons 0 "MTEXT") (cons -4 "OR>") (cons -4 "<OR") (cons 8 "TEXT_STAGE NUMBER_LISP") (cons 8 "TEXT_LOT NUMBER_LISP") (cons 8 "POLY*") (cons -4 "OR>") (cons -4 "AND>") ) ) ) ;; Could be simplified to this (setq allents (ssget "_P" '((0 . "TEXT,MTEXT") (8 . "TEXT_STAGE NUMBER_LISP,TEXT_LOT NUMBER_LISP,POLY*")) ) ) 1 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.