Jump to content

Recommended Posts

Posted (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 by Sambo
Posted

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))
)
)

 

  • Like 1
Posted

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. 

Posted

@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*"))
	  )
)

 

  • Like 1
  • Agree 1

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...