wimal Posted June 1, 2013 Posted June 1, 2013 (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 Quote
lyky Posted June 1, 2013 Posted June 1, 2013 (edited) (setq tset (ssget '((0 . "*TEXT"))) i 0) (while (< i (sslength tset)) (setq SS3 (ssadd (ssname tset i) SS3)) (1+ i)) Edited June 1, 2013 by lyky Quote
Tharwat Posted June 1, 2013 Posted June 1, 2013 (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) ) ) Quote
fixo Posted June 1, 2013 Posted June 1, 2013 (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 June 1, 2013 by fixo thanks Tharwat Quote
Tharwat Posted June 1, 2013 Posted June 1, 2013 (ssadd coll en) I guess it is on the contrary (ssadd en coll) Quote
fixo Posted June 1, 2013 Posted June 1, 2013 I guess it is on the contrary (ssadd en coll) Thanks , fixed above Quote
Tharwat Posted June 1, 2013 Posted June 1, 2013 (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 . Quote
wimal Posted June 1, 2013 Author Posted June 1, 2013 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)) Quote
Lee Mac Posted June 1, 2013 Posted June 1, 2013 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. Quote
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.