Jump to content

Recommended Posts

Posted

I have a list with multiple selection sets, i want to join them into a single selection set, ho?

  • Replies 22
  • Created
  • Last Reply

Top Posters In This Topic

  • drafter007

    6

  • pBe

    5

  • Lee Mac

    4

  • MSasu

    3

Top Posters In This Topic

Posted

Parse them with SSNAME, first item had index 0, and add to the first one using SSADD function. To get the size of a selection set use SSLENGTH.

Posted

maybe something like this would work ..... Try it ...

 

(setq s (ssget))

(setq ss (ssget))

(repeat (setq i (sslength s))
 (ssadd (ssname s (setq i (1- i))) ss)
)

Posted

You can use ACET functions for Selection sets :

 

(setq sss (acet-ss-union (list ss1 ss2 ss3 ... ssn)))

 

M.R.

Posted

Only with express tools... nobody has a function similar to acet-ss-union?

Posted

It is a mater of minutes to write one by yourself using the info above. If you got stuck, then post your attempt here for debug support.

Posted
Only with express tools... nobody has a function similar to acet-ss-union?

 

What exactly do you have in mind drafter007? It appears that tharwats snippet will accomplish what you need.

Posted

The Express function work with any number of selection sets, while Tharwat's example is limited to only two. I think that this is the reason of OP's complain. But said example code can be used effectively as a starting point to a dedicated function similar with the one from Express pack. This should be easy taking into consideration that OP had already some experience playing with selection sets.

Posted
..... But said example code can be used effectively as a starting point to a dedicated function....

 

That is correct , I meant to say exactly that ;)

Posted

But i still want to see a function made by some guys with more experience ...please... :)

Posted
But i still want to see a function made by some guys with more experience ...please... :)

 

You should be thankful for all people whom treated you as a man to help you out with your question and not to be ungrateful . :glare:

Posted

Here is one way:

 

;; Selection Set Union  -  Lee Mac
;; Returns the union of a list of Selection Sets

(defun LM:ss-union ( lst / out )
   (setq lst (vl-sort lst '(lambda ( a b ) (> (sslength a) (sslength b))))
         out (car lst)
   )
   (foreach ss (cdr lst)
       (repeat (setq i (sslength ss))
           (ssadd (ssname ss (setq i (1- i))) out)
       )
   )
   out
)

 

Here is a 'cheats' way:

 

(defun ss-union ( lst )
   (apply 'vl-cmdf (append '("_.select") lst '("")))
   (ssget "_P")
)

Posted

Thanks Lee! One more beer i owe you... :)

Posted
Here is one way:

 

(defun LM:ss-union ( lst / out ).....
.....
)

 

There you go :)

 

After looking the linky MSasu posted on his previous post. My thought was the "list with multiple selection sets" you are refering to are a list of enames as elements. but reading further ahead , you change your aapproach to collecting points then

ssget "_CP"

 

But anyhoo, Hope you dont mind me asking, are those selection sets resulted from a single call to a lisp routine?

Posted

Yes, a single call, but i modified the lisp to have multiple selection - multiple points of selection - so i have a list with multiple selection sets... :)

Sorry for my way of working and for my bad explanations...

Posted
Thanks Lee! One more beer i owe you... :)

 

You're welcome drafter007, though, I would encourage you to attempt to code these tasks yourself before expecting a solution to be provided.

Posted
Only with express tools... nobody has a function similar to acet-ss-union?

 

Every AutoCAD has ACET functions loaded and no need to do anything but use them...

 

My solution is fastest as it was made by Autodesk for exactly these purposes...

 

You can also check :

(acet-ss-remove (smaller ss2) (bigger ss1)) - returns ss difference (ss1-ss2)

(acet-ss-intersection ss1 ss2) - returns ss with objects that are both in ss1 and ss2

 

(acet-ss-union (list ss1 ss2 ss3 ... ssn)) - returns ss addition (ss1+ss2+ss3+...+ssn)

 

M.R.

Posted

I'll go with the OP on this one Marko. I would think its not the just having to use a particular function that interest the OP, but how it was done

 

I applaud the forum members who help/assist/advice/suggest and even write the code itself to help others. :thumbsup:

 

Cheers

Posted

pBe, I've also tried this once on www.augi.com :

http://forums.augi.com/showthread.php?138426-sel-sets-subfunctions&p=#1

 

But results were slow if ssets were large, so after a while doing my research on this topic, my conclusion was that the best thing is to use already predefined functions... Maybe, you don't agree with me, but to me they do the job fine and more important I think faster then any of above proposed codes...

 

M.R.

(test it and if you disagree reply...)

Posted
Every AutoCAD has ACET functions loaded and no need to do anything but use them...

 

Some users don't have Express Tools installed / loaded.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...