lamensterms Posted August 22, 2012 Share Posted August 22, 2012 Hey guys, Just wondering a way to create 2 secondary selection sets from 1 primary one. My situation is.. i want to be able to select a bunch of lines/arcs/elipses/etc which will be one 1 of two layers (layers name 1H and 5C). The entities on layer 1H i wish to erase and the entities on layer 5C i wish to colour yellow. I dont have an example code or anything - it is at work. I was just hoping someone could let me know how to use 'Selection Set 1' to create 'Selection Set 2' and 'Selection Set 3'. I know which filters I need... just not how to apply them twice to the first Selection Set. Thanks for any help. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 22, 2012 Share Posted August 22, 2012 Hi . After you have collected a selection set you can step through it for a specific conditions you want , by Layers , Entities ... etc - Make an empty selection set like this ( setq s (ssadd)) - Step through you first selection set , and when it match your criteria , add that entity name to the new selection set which is s in our first step like this (ssadd s) - At the end you would have a new selection set of your desire conditions if your criteria found with the selection set entity name . Good luck. Tharwat Quote Link to comment Share on other sites More sharing options...
MSasu Posted August 22, 2012 Share Posted August 22, 2012 Since there are no common processing(s) for the two groups, is better to build two selection sets. This way will have a much simple code and the processing will be faster, too. (ssget "_X" '((0 . "LINE,ARC,ELLIPSE") (8 . "1H"))) ;1st selection set (ssget "_X" '((0 . "LINE,ARC,ELLIPSE") (8 . "5C"))) ;2nd selection set Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 22, 2012 Share Posted August 22, 2012 Since there are no common processing(s) for the two groups, is better to build two selection sets. This way will have a much simple code and the processing will be faster, too. (ssget "_X" '((0 . "LINE,ARC,ELLIPSE") (8 . "1H"))) ;1st selection set (ssget "_X" '((0 . "LINE,ARC,ELLIPSE") (8 . "5C"))) ;2nd selection set This method would be suitable providing that the OP wishes to operate on all of the objects on each of the respective layers. Should the OP wish to manually select a number of objects on each layer, I would restrict the initial set to only permit objects on either layer "1H" or "5C", then use an if statement whilst iterating over the set to determine how each object should be processed based on its layer. Also, note that by collecting two selection sets using the "_X" mode string, the entire drawing database is being traversed twice to retrieve the sets, which are then processed separately. For this particular situation, I would be inclined to use something like: (if (setq s (ssget "_:L" '((0 . "LINE,ARC,ELLIPSE") (8 . "1H,5C")))) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) l (entget e) ) (if (= "1H" (cdr (assoc 8 l))) <do something> <do something else> ) ) ) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 22, 2012 Share Posted August 22, 2012 Since that you would use the same selection set for the same purpose , you should just step through the of each selection set . e.g. (if (setq ss (ssget "_:L" '((0 . "LINE,ARC,ELLIPSE")(8 . "1H,5C")))) (repeat (setq i (sslength ss)) (setq sn (ssname ss (setq i (1- i)))) (setq l (cdr (assoc 8 (setq e (entget sn))))) (cond ((eq l "H1") (entdel sn)) ((eq l "5C") (if (cdr (assoc 62 e)) (entmod (subst (cons 62 2) (assoc 62 e) e)) (entmod (append e (list (cons 62 2)))) ) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
lamensterms Posted August 22, 2012 Author Share Posted August 22, 2012 Hi guys, Thanks so much for your fast replies. Tharwat - I managed to get your routine to do exactly what I need (i think). The code is a little too sophisticated for me to understand, but it does work so thank you for that. Thanks as well Lee, I couldnt figure out how to apply the actions to your code. I've still got so much to learn with LISP - but I'm finding less and less time to study it. Thanks again everyone. (DEFUN C:TEST () (if (setq ss (ssget "_:L" '((0 . "LINE,ARC,ELLIPSE")(8 . "1H,5C")))) (repeat (setq i (sslength ss)) (setq sn (ssname ss (setq i (1- i)))) (setq l (cdr (assoc 8 (setq e (entget sn))))) (cond ((eq l "1H") (entdel sn)) ((eq l "5C") (if (cdr (assoc 62 e)) (entmod (subst (cons 62 2) (assoc 62 e) e)) (entmod (append e (list (cons 62 2)))) ) ) ) ) (princ) ) ) .... Just for reference. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 22, 2012 Share Posted August 22, 2012 Hi guys, Tharwat - I managed to get your routine to do exactly what I need (i think). The code is a little too sophisticated for me to understand, but it does work so thank you for that. (DEFUN C:TEST [color=red][b](/ ss i sn l e)[/b][/color] You 're welcome , you should localize your variables as modified above . Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 22, 2012 Share Posted August 22, 2012 You're welcome. Since there are only two cases (1H or 5C), I think an if statement is more suited (and more readable) over the cond, and the code could be shortened to: (defun c:doit ( / e i l s ) (if (setq s (ssget "_:L" '((0 . "LINE,ARC,ELLIPSE") (8 . "1H,5C")))) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) l (entget e) ) (if (= "1H" (cdr (assoc 8 l))) (entdel e) (entmod (append l '((62 . 2)))) ) ) ) (princ) ) Or, if you like to nest the expressions: (defun c:doit ( / e i l s ) (if (setq s (ssget "_:L" '((0 . "LINE,ARC,ELLIPSE") (8 . "1H,5C")))) (repeat (setq i (sslength s)) (if (= "1H" (cdr (assoc 8 (setq l (entget (setq e (ssname s (setq i (1- i))))))))) (entdel e) (entmod (append l '((62 . 2)))) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
MSasu Posted August 23, 2012 Share Posted August 23, 2012 Should the OP wish to manually select a number of objects on each layer I believe that I misread OP's requirement. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 23, 2012 Share Posted August 23, 2012 I believe that I misread OP's requirement. No worries Mircea 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.