Aftertouch Posted October 28, 2022 Posted October 28, 2022 Hi all, I got 2 criteria of selection wich i wanna use to make 1 selectionset... I want all blocks of a predefined layername and blockname list I want all line,arc and polyline of a predefinied layername list... Can this be written in 1 ssget function? If not... how to easily combine both? thanks in advance. (setq ssvalid (ssget "_X" (list (cons 0 "INSERT" (cons 8 validlisttotal) (cons 2 validlisttotalblocks)))) (setq ssvalid (ssget "_X" (list (cons 0 "LINE,ARC,LWPOLYLINE" (cons 8 validlisttotal)))) Quote
Steven P Posted October 28, 2022 Posted October 28, 2022 Maybe this will help, http://lee-mac.com/ssget.html, looking towards the bottom and the 'or' option, you want to select entities that are blocks OR lines (use the description in the AND box above for a good example, changing it to OR of course) If your code is working nicely though a bit long, not changing anything that works (always good...) this https://www.afralisp.net/autolisp/tutorials/selection-sets.php has a description of how to add 2 existing selection sets together (about 2/3 of the way down the page, creating a 'union' between selection sets). Not sure what happens if an entity is in both sets, probably will exist twice in the new selection set and be processed twice subsequently. 1 Quote
mhupp Posted October 28, 2022 Posted October 28, 2022 Best to use the Logical Operators shown in lee mac's website to create one selection set like Steven says. While afralisp also works I don't like to use counters so here is the foreach way. (setq SS (ssget "_X" (list (cons 0 "INSERT") (cons 8 validlisttotal) (cons 2 validlisttotalblocks)))) ;was missing ) on (cons 0 INSERT (setq SS1 (ssget "_X" (list (cons 0 "LINE,ARC,LWPOLYLINE") (cons 8 validlisttotal)))) ;use a diffrent selection set name (foreach ent (mapcar 'cadr (ssnamex SS1)) ;builds a list of entity names from selection set ss1 (ssadd ent ss) ;adds each entity from ss1 to ss ) 1 Quote
Aftertouch Posted October 28, 2022 Author Posted October 28, 2022 Thanks for the suggestions, i think i found a simple one... (setq ssvalid1 (ssget "_X" (list (cons 0 "INSERT") (cons 8 validlisttotal) (cons 2 validlisttotalblocks)))) (setq ssvalid2 (ssget "_X" (list (cons 0 "LINE,ARC,LWPOLYLINE") (cons 8 validlisttotal)))) (setq ssvalid (acet-ss-union (list ssvalid1 ssvalid2))) Works like a charm! 2 Quote
mhupp Posted October 28, 2022 Posted October 28, 2022 (edited) Nice learning something every day! Edited October 29, 2022 by mhupp Quote
ronjonp Posted October 28, 2022 Posted October 28, 2022 3 hours ago, Aftertouch said: Hi all, I got 2 criteria of selection wich i wanna use to make 1 selectionset... I want all blocks of a predefined layername and blockname list I want all line,arc and polyline of a predefinied layername list... Can this be written in 1 ssget function? If not... how to easily combine both? thanks in advance. (setq ssvalid (ssget "_X" (list (cons 0 "INSERT" (cons 8 validlisttotal) (cons 2 validlisttotalblocks)))) (setq ssvalid (ssget "_X" (list (cons 0 "LINE,ARC,LWPOLYLINE" (cons 8 validlisttotal)))) Nothing will work with your examples because they are invalid to begin with. Try this untested: (ssget "_X" (list '(-4 . "<OR") '(-4 . "<AND") '(0 . "INSERT") (cons 8 validlisttotal) (cons 2 validlisttotalblocks) '(-4 . "AND>") '(-4 . "<AND") '(0 . "LINE,ARC,LWPOLYLINE") (cons 8 validlisttotal) '(-4 . "AND>") '(-4 . "OR>") ) ) 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.