Jump to content

Recommended Posts

Posted

(setq tset (ssget "_C" pw1 pw2 '((0 . "text" ))))
(if (/= tset nil)
 (setq ss3(ssadd tset ss3))
 )

I need to add the all selected texts by several windows to a single set.

Please correct my code

Posted (edited)
(setq tset (ssget '((0 . "*TEXT"))) i 0)
(while (< i (sslength tset))
(setq SS3 (ssadd (ssname tset i) SS3))
(1+ i))

Edited by lyky
Posted
(setq ss3 (ssadd))

(if (setq tset (ssget "_C" pw1 pw2 '((0 . "TEXT"))))
 (repeat (setq i (sslength tset))
   (ssadd (ssname tset (setq i (1- i))) ss3)
 )
)

Posted (edited)
(setq tset (ssget "_C" pw1 pw2 '((0 . "text" ))))
(if (/= tset nil)
 (setq ss3(ssadd tset ss3))
 )

I need to add the all selected texts by several windows to a single set.

Please correct my code

Probably try some thing like this


(setq coll (ssadd))


(while(and (setq p1 (getpoint "\nFirst corner: "))


(setq p2 (getcorner p1  (getpoint "\nOpposite corner: "))


(setq tset (ssget "_W" p1 p2 '((0 . "text" ))))


(while (setq en (ssname tset 0))


(ssadd en coll)


(ssdel en tset)))))


(alert (strcat "Collected: " (itoa (sslength coll))))

not tested though, just from the top of my head

Edited by fixo
thanks Tharwat
Posted

(ssadd coll en)

 

I guess it is on the contrary :)

 

(ssadd en coll)

Posted
I guess it is on the contrary :)

 

(ssadd en coll)

Thanks , fixed above

Posted
(setq SS3 (ssadd (ssname tset i) SS3))

 

There is no need to assign the new adds to the variable ss3 every time you add more entities to it , it's enough like this .

 

(ssadd <entity> SS3)

 

Thanks , fixed above

You're welcome .

Posted

Thank for all. I used your codes this way.

(setq tset (ssget "_C" pw1 pw2 '((0 . "text" ))))
(setq en (ssname tset 0))
 (setq ss3(ssadd en ss3))

Posted

Here is my take on merging multiple selection sets:

[color=GREEN];; Selection Set Union  -  Lee Mac[/color]
[color=GREEN];; Returns the union of a list of Selection Sets[/color]

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

And here is a shortcut method providing all selection sets are in the same space:

([color=BLUE]defun[/color] ss-union ( lst )
   ([color=BLUE]apply[/color] '[color=BLUE]vl-cmdf[/color] ([color=BLUE]append[/color] '([color=MAROON]"_.select"[/color]) lst '([color=MAROON]""[/color])))
   ([color=BLUE]ssget[/color] [color=MAROON]"_P"[/color])
)

Call with list of selection sets.

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...