Is There a Way to Increment the Selection Set Name in a Loop

Is There a Way to Increment the Selection Set Name in a Loop

mgorecki
Collaborator Collaborator
799 Views
9 Replies
Message 1 of 10

Is There a Way to Increment the Selection Set Name in a Loop

mgorecki
Collaborator
Collaborator

For example I have a number of rectangular polylines on a layer.  The groups of rectangles have different sizes.  I'll ask the user to select a group and I want to store them in a unique selection set name, then loop and have them select the next set and store them in a unique selection set name, and so on.

Any ideas on how to do this?

Thanks

0 Likes
Accepted solutions (2)
800 Views
9 Replies
Replies (9)
Message 2 of 10

Kent1Cooper
Consultant
Consultant
Accepted solution

This is a job for the (set) function, in which you can construct a variable name involving other functions.  In your description:

 

(setq n 0)

(while

  (set (read (strcat "ss" (itoa (setq n (1+ n))))) (ssget '((0 . "LWPOLYLINE") (8 . "YourLayerName"))))

)

 

That will save the first selection to a variable called ss1, the next to ss2, etc.

Kent Cooper, AIA
0 Likes
Message 3 of 10

komondormrex
Mentor
Mentor
Accepted solution

list 'em like that

(setq sset_list nil
      loop t
)
(while loop
	(setq sset_list (append sset_list (list (ssget))))
)

and then get each sset usins nth function.

(sssetfirst (nth 0...n  sset_list))

0 Likes
Message 4 of 10

mgorecki
Collaborator
Collaborator

Hi Kent, thank you very much!

0 Likes
Message 5 of 10

mgorecki
Collaborator
Collaborator

Thank you very much as well, I though about using a list.

0 Likes
Message 6 of 10

komondormrex
Mentor
Mentor

your welcome. it is LISt Processing)

0 Likes
Message 7 of 10

Sea-Haven
Mentor
Mentor

Any reason why you would not make a list ( (layer entityname)(layer entityname)(layer entityname)....

 

The list could have even more items (layer entityname area length) etc. You can sort the list based on any sub item. 

0 Likes
Message 8 of 10

Kent1Cooper
Consultant
Consultant

@Sea-Haven wrote:

Any reason why you would not make a list ( (layer entityname)(layer entityname)(layer entityname)....

....


[Nothing in the request relates to Layers.]  A big difference:  my solution puts entire selection sets, of any number of objects, not just one entity, and on any number of Layers, into incremented-name variables [see the Topic heading].  But the OP would have to say whether that list approach can serve their purpose.

Kent Cooper, AIA
0 Likes
Message 9 of 10

mgorecki
Collaborator
Collaborator

And here I thought it stood for Lost In Stupid Parenthesis 😄

0 Likes
Message 10 of 10

mgorecki
Collaborator
Collaborator

Hello, no particular reason except that I just wanted to have different selection sets to manipulate later in the code.  I agree, Lists are very helpful, I use them a lot.

0 Likes