3dwannab Posted October 10 Posted October 10 (edited) Hi all, I've googled to look for the solution to select objects using the ssget filter to select objects that DON'T have a DXF code. Lee Mac's help page didn't have any examples either. I also want to combine it with the filter below, which selects objects with DXF code 210 that are not (0,0,1), which works in itself. This DXF is for the extrusion of an object. (setq ss (ssget "_:L" '((-4 . "<NOT") (210 0.0 0.0 1.0) (-4 . "NOT>")))) Edited October 10 by 3dwannab Quote
Steven P Posted October 10 Posted October 10 (edited) Try 2 selection sets, delete each item in dxf 210 selection set from the other one: (untested) (setq ss (ssget "_:L" '((-4 . "<NOT") (210 0.0 0.0 1.0) (-4 . "NOT>")))) (setq ss2 (ssget "_:L" )) (setq acount (sslength ss)) (while (> acount 0) (setq ss2 (ssdel (ssname ss acount) ss2)) (setq acount (- acount 1)) ) ; end while .. something like that... ss2 will be everything that is containing (210 0.0 0.0 1.0) in this example, ss is everything that is NOT (210 0.0 0.0 1.0) .. do the reverse to add items from selection sets together: (setq ss (ssget "_:L" '((-4 . "<NOT") (210 0.0 0.0 1.0) (-4 . "NOT>")))) (setq ss2 (ssget "_:L" '((-4 . "<NOT") (210 1.0 1.0 1.0) (-4 . "NOT>")))) (setq acount (sslength ss)) (while (> acount 0) (setq ss2 (ssadd (ssname ss acount) ss2)) (setq acount (- acount 1)) ) ; end while This example will give everything containing NOT (210 0.0 0.0 1.0) and NOT (210 1.0 1.0 1.0).. (should be everything actually just the way I've done it). ssadd will only add if the item isn't existing in the selection set added to With ssadd it might be more efficient to check which is the shorter selection set to loop through and add to the larger - depends on how large the sets are. not sure if this helps? Edit: What are the 2 criteria you are searching for by the way? Edited October 10 by Steven P Quote
3dwannab Posted October 10 Author Posted October 10 (edited) No, I just want to filter any entities that are missing the DXF code 210 and also select those that do not have (0,0,1) in DXF code 210. Here's what I have currently but the problem with this is that it doesn't show a preview like an ssget filter and seems like it is a lot slower as it has to iterate over all the entities. ;; Filter objects that don't contain the dxf code 210 and that have ones that are not (0,0,1) ;; Written on 2024.10.09 by 3dwannab (defun c:QSExtrusionBad (/ dxf210 ent entData ss valid-ss) (setq ss (ssget "_:L")) ; Select all objects (setq valid-ss (ssadd)) ; Create an empty selection set for valid objects ;; Check if selection set exists (if ss (progn ;; Loop through each object in the selection set (repeat (sslength ss) (setq ent (ssname ss 0)) ; Get the entity name (setq entData (entget ent)) ; Get the entity data ;; Get the value of DXF code 210 (setq dxf210 (cdr (assoc 210 entData))) ;; Check if the DXF code 210 exists and is not equal to (0, 0, 1) (if (and dxf210 (not (equal dxf210 '(0.0 0.0 1.0)))) (ssadd ent valid-ss) ; Add the valid object to the new selection set ) ;; Remove the checked entity from the original selection set (setq ss (ssdel ent ss)) ) ;; Set the filtered selection as the current active selection (if (> (sslength valid-ss) 0) (progn (sssetfirst nil valid-ss) (prompt (strcat "\n" (itoa (sslength valid-ss)) " valid objects found and selected.")) ) (prompt "\nNo valid objects found.") ) ) (prompt "\nNo objects found.") ) (princ) ) Edited October 10 by 3dwannab Quote
Steven P Posted October 10 Posted October 10 (edited) Try this as an explanation what you might want to look at: (ref Lee Mac ssget reference and noting that the criteria for anything goes and includes the dxf code number too ie x, y, z list needs 4 options to be fully assessed. dxf, x, y, z) ... think you are experienced enough to decipher my ramblings! EDIT... forget that... not sure if this works.... (defun c:test ( / ) ;; Simple filter to (210 0.0 0.0 1.0) (princ "\nFirst Selection Set: ") (setq All (ssget '( (210 0.0 0.0 1.0)))) ;; Anything Goes, dxf 210 codes, filter: (= 210, 3x 'wildcards' at 1.0 2.0 3.0) ;; i.e. all values of code 210 (princ "\nSecond Selection Set: ") (setq Allxxx (ssget '((-4 . "=,*,*,*") (210 1.0 2.0 3.0)))) ;; Anything goes, dxf 210 codes, filter (= 210, wild card, wild card, not equal to 1 ;; i.e. filtered dxf code 210 anything except z value of 1.0 (princ "\nThird Selection Set: ") (setq Allxxn (ssget '((-4 . "=,*,*,!=") (210 0.0 0.0 1.0)))) ;;Report: (princ "\nFirst : ")(if All (princ (sslength All))(princ "nil")) (princ " Second : ")(if Allxxx (princ (sslength Allxxx))(princ "nil")) (princ " Third : ") (if Allxxn (princ (sslength Allxxn))(princ "nil")) (princ) ) Edited October 10 by Steven P Quote
Steven P Posted October 10 Posted October 10 Might be wrong with the above, but (setq MySS (ssget "_X" '( (-4 . "!=") (210 0 0 1)))) I think returns everything without (210 0 0 1) code.. waiting for better minds to wake up in the morning or get a chance at lunchtime Quote
3dwannab Posted October 13 Author Posted October 13 On 10/10/2024 at 9:54 PM, Steven P said: Might be wrong with the above, but (setq MySS (ssget "_X" '( (-4 . "!=") (210 0 0 1)))) I think returns everything without (210 0 0 1) code.. waiting for better minds to wake up in the morning or get a chance at lunchtime Is this not the same way of writing this that I posted in my first post? (setq ss (ssget "_:L" '((-4 . "<NOT") (210 0.0 0.0 1.0) (-4 . "NOT>")))) 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.