I have made a selection set and i need to make a copy of this one how can i do.
Thanks
@Kulfi wrote:
I have made a selection set and i need to make a copy of this one how can i do.
Thanks
I assume from the Subject that you mean you want to save another selection set containing the same entities as the first one, rather than to make copies in the drawing of the entities in it. I'll use ss1 as the name of the set you have already made, and ss2 for the copy. I expected that this:
(setq ss2 ss1)
would work, but I find that if I then remove something from ss1 using (ssdel), it is also no longer a part of ss2. But stepping through ss1 and adding each entity to ss2, for example like this, works:
(repeat (setq inc (sslength ss1))
(ssadd (ssname ss1 (setq inc (1- inc))) ss2)
)
Then removing something from ss1 does not also remove it from ss2.
@Kulfi wrote:
I have made a selection set and i need to make a copy of this one how can i do.
Thanks
Kulfi,
I do agree with Kent1Cooper interpretation of your question, but not with the method.
To create a selection set copy, I would use something like
(if (setq ss1 (ssget)) (progn (setq ss2 (ssadd) i -1) (repeat (sslength ss1) (ssadd (ssname ss1 (setq i (1+ i))) ss2)
) ) )
the
(repeat (setq i (sslength ss1)) (ssadd (ssname ss1 (setq inc (1- i))) ss2) )
method, will create a selection set with the entities in reversed order, so (nth x ss1) is not the same as (nth x ss2)...
HTH
Henrique
@hmsilva wrote:
...the
(repeat (setq i (sslength ss1)) (ssadd (ssname ss1 (setq inc (1- i))) ss2) )method, will create a selection set with the entities in reversed order, so (nth x ss1) is not the same as (nth x ss2)...
....
Good point -- of course, whether it matters would depend on what use is being made of the sets, but keeping the order the same covers all bases.
I had also neglected to put in the (setq ss2 (ssadd)) part, to start the copy set, but then found [in actually trying it -- what a concept!] that without that, it doesn't like being asked to add to it.
@Kent1Cooper wrote:
I had also neglected to put in the (setq ss2 (ssadd)) part, to start the copy set, but then found [in actually trying it -- what a concept!] that without that, it doesn't like being asked to add to it.
Did you tried in a new drawing, or (setq ss2 nil) before?
Henrique
Shouldn't the "I" and the "INC" variables be the same in your example there Kent?
For de/incrementing the counter/selset variable, that is?
That is some good stuff Kent. Thanks.
I guess both situations could be useful, and it depends on what you are trying to do.
@bhull1985 wrote:
Shouldn't the "I" and the "INC" variables be the same in your example there Kent?
For de/incrementing the counter/selset variable, that is?
Brandon,
It was I who didn't change the inc to i, when I was exemplifying the method, not Kent1Cooper.
Kent1Cooper's code inc variable is always inc, not i...
My bad.
Henrique
Oh I see! Alright, was just noticing that they were using different variables and as such would not pick up the changes within the while loop to the counter var (because they were named differently and the way those incrementors work in loops is by renaming the same variable to keep a running count), if i understand correctly.
🙂
@bhull1985 wrote:
Shouldn't the "I" and the "INC" variables be the same in your example there Kent? ....
They are both the same [inc] in my original [Message 3] -- it appears hmsilva switched one of them, but not the other, to the i they used, in [mis]quoting mine in Message 4. [EDIT: ...and now I see hmsilva acknowledged that -- mea culpa for not following the thread further before responding.]
@hmsilva wrote:
@Kent1Cooper wrote:I had also neglected to put in the (setq ss2 (ssadd)) part, to start the copy set, ... without that, it doesn't like being asked to add to it.
Did you tried in a new drawing, or (setq ss2 nil) before?
I actually tried it in the same drawing in which I had been twiddling with ss1 and ss2, but I used ss3 and ss4 instead, and also [arbitrarily] ss8 and ss9. In each case, without having yet established an empty selection set under the second name, I got this:
; error: bad argument type: lselsetp nil
because there was nothing to add to.
@Kent1Cooper wrote:
@hmsilva wrote:
@Kent1Cooper wrote:I had also neglected to put in the (setq ss2 (ssadd)) part, to start the copy set, ... without that, it doesn't like being asked to add to it.
Did you tried in a new drawing, or (setq ss2 nil) before?
I actually tried it in the same drawing in which I had been twiddling with ss1 and ss2, but I used ss3 and ss4 instead, and also [arbitrarily] ss8 and ss9. In each case, without having yet established an empty selection set under the second name, I got this:
; error: bad argument type: lselsetp nil
because there was nothing to add to.
Firstly, my apologies Kent.
When I first read "without that, it doesn't like being asked to add to it.", I understood "without that, it does like being asked to add to it." that was the reason I asked if you did try in a new drawing, or (setq ss2 nil) before...
My mistake.
Henrique