vanowm Posted September 15, 2015 Share Posted September 15, 2015 (edited) Hello. I probably missing something obvious here, but how do I apply filters with SSGET to different selection sets (created with SSADD)? Just a quick and crude example which doesn't work (obviously): ; ss1 and ss2 are two different selection sets. How they were created is irrelevant. (print (sslength ss1)) ;apply filter to ss1 selection set ;(setq ss1 (ssget ss1 '((8 . "Layer2")))) (print (sslength ss1)) in this example ss1 and ss2 are two different selection sets (how they were created is irrelevant), and I'm looking for a way apply a filter on them if possible without going through each entity in the set separately unless it's most optimized solution. Thank you. Edited September 15, 2015 by vanowm Dumbing down the example, because evidently making an usable example makes it too confusing for some people... Quote Link to comment Share on other sites More sharing options...
BIGAL Posted September 15, 2015 Share Posted September 15, 2015 I think this is what you want (setq ss1 (ssget "X" '((0 . "LINE")(8 . "Layer2"))) or you can make a new selection set by using ssadd but checking if the (assoc 8 "Layer2") is true for each item in ss1 Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 15, 2015 Share Posted September 15, 2015 Are you after cycling through the already created selection set to check if any object in the fore-said selection set is matching a specific name of layer then create a new selection set ? Quote Link to comment Share on other sites More sharing options...
vanowm Posted September 15, 2015 Author Share Posted September 15, 2015 (edited) No, not really, I was trying avoid looping through the set. So far the only solution I could come up that doesn't require loop through the set is to use SSSETFIRST: ; ss1 and ss2 are two different selection sets. How they were created is irrelevant. (print (sslength ss1)) ;number of entities before the filter (setq ss_orig (ssget "_I")) ; save original selection (sssetfirst nil ss1) ;force selection with new set (setq ss1 (ssget "_I" '((8 . "Layer2")))) ;apply the filter (print (sslength ss1)) ;number of entities after the filter (if ss_orig (sssetfirst nil ss_orig) ;restore original selection ) I don't know if this is most efficient way of doing it though. Edited September 15, 2015 by vanowm Quote Link to comment Share on other sites More sharing options...
tombu Posted September 15, 2015 Share Posted September 15, 2015 No, not really, I was trying avoid looping through the set. So far the only solution I could come up that doesn't require loop through the set is to use SSSETFIRST: I don't know if this is most efficient way of doing it though. BIGAL's code looked a lot simpler to me. Quote Link to comment Share on other sites More sharing options...
vanowm Posted September 15, 2015 Author Share Posted September 15, 2015 BIGAL's code looked a lot simpler to me. Yes, it does, if you totally disregard my original post, such as using "X" mode will filter through every single entity in the drawing, but I need apply the filter to only specific set of entities. Quote Link to comment Share on other sites More sharing options...
tombu Posted September 15, 2015 Share Posted September 15, 2015 Yes, it does, if you totally disregard my original post, such as using "X" mode will filter through every single entity in the drawing, but I need apply the filter to only specific set of entities. But that's exactly the same thing you're doing. (setq ss1 (ssget "X" '((0 . "LINE"))) He just combined the filters for you. If you put the entire code up or just what you want the code to do it we would be better able to provide answers. Quote Link to comment Share on other sites More sharing options...
vanowm Posted September 15, 2015 Author Share Posted September 15, 2015 in this example I'm using "X" to create selection sets, but in my script these sets are custom created via SSADD therefore I cannot use filters before/during selection set is created, I need apply them AFTER selection set is created. Yes, it does, if you totally disregard my original post I rest my case. Quote Link to comment Share on other sites More sharing options...
tombu Posted September 15, 2015 Share Posted September 15, 2015 I rest my case. You posted no code using SSADD providing a more "efficient way of doing it" requires actually being able to see how you're doing it now. So again: "If you put the entire code up or just what you want the code to do it we would be better able to provide answers. " Quote Link to comment Share on other sites More sharing options...
jdiala Posted September 15, 2015 Share Posted September 15, 2015 Yes, it does, if you totally disregard my original post, such as using "X" mode will filter through every single entity in the drawing, but I need apply the filter to only specific set of entities. I believe this is what you want. To filter lines on a specific layer and circle. Remove the "_x" if you want to select manually. (setq ss (ssget "_x" '( (-4 . "<OR") (-4 . "<AND") (0 . "LINE") (8 . "Layer2") (-4 . "AND>") (-4 . "<AND") (0 . "CIRCLE") (-4 . "AND>") (-4 . "OR>") ) ) ) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 15, 2015 Share Posted September 15, 2015 [color=magenta](-4 . "<AND")[/color] (0 . "CIRCLE")[color=magenta] (-4 . "AND>")[/color] I think there is no need for the two DXFs and since you have only one name of entity and without any further DXF filters. Quote Link to comment Share on other sites More sharing options...
jdiala Posted September 15, 2015 Share Posted September 15, 2015 I think there is no need for the two DXFs and since you have only one name of entity and without any further DXF filters. At first that was my initial code, since OP is not used with logical operator on ssget it wouldn't hurt to add the "and" operand so he can filter the circle further if he want to. Quote Link to comment Share on other sites More sharing options...
vanowm Posted September 15, 2015 Author Share Posted September 15, 2015 I've updated original post. I hope it clears things up better. And I'll repeat myself one more time: (SSGET "_X") will not work, because it will apply to all entities in the drawing, and not to specific entities in the already defined selection set. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted September 16, 2015 Share Posted September 16, 2015 Go back to my post do you know how to go through a selection set and inspect it further re (assoc 8 (ssname x ss1)) then use ssadd to make a new selection set. Quote Link to comment Share on other sites More sharing options...
jdiala Posted September 16, 2015 Share Posted September 16, 2015 I've updated original post. I hope it clears things up better. And I'll repeat myself one more time: (SSGET "_X") will not work, because it will apply to all entities in the drawing, and not to specific entities in the already defined selection set. here, filter ss1 with layer. (filter-ss ss1 "Layer2") (defun filter-ss ( ss1 lay / i lst ) (repeat (setq i (sslength ss1)) (if (not (= lay (cdr (assoc 8 (entget (setq e (ssname ss1 (setq i (1- i)) ) ) ) ) ) ) ) (setq lst (cons e lst)) ) ) (mapcar (function (lambda (a) (ssdel a ss1) ) ) lst ) ) Quote Link to comment Share on other sites More sharing options...
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.