Jump to content

selecting multiple layers filtered with one window HELP!!


Recommended Posts

Posted

I am currently using ssget to select layers i want to include in my lisp program but as you can see below i have to drag a window on the drawing 4 times to save each layer to a set. I was wondering if there is a way to select one window around the objects (instead of repeating it four times) and it filters out the layers i want and saves them to four different SETQ.

Below is what i wrote in the program currently

 

(prompt "\nSelect the Lines to be Added together:")

(setq ss1 (ssget (list (cons 8 "layer1"))))

(setq ss2 (ssget (list (cons 8 "layer2"))))

(setq ss3 (ssget (list (cons 8 "layer3"))))

(setq ss4 (ssget (list (cons 8 "layer4"))))

 

As you can see i have to ssget four times, just wondered if i can use it once and is stores in SS1, SS2, SS3, SS4

 

Thanks

 

Andrew

Posted

You can use the "_x" after each ssget to get them automatically .

 

Example .

 

(setq ss1 (ssget[color=red][b] "_x"[/b][/color] (list (cons 8 "layer1"))))

Implement the above example to all your codes.

 

Tharwat

Posted

Try this:

 

 
(defun c:test ()
  (setq 
        ss_set '("ss1" "ss2" "ss3")cnt -1)
(foreach
           layername (list "Layer1" "Layer2" "Layer3")
          (set (setq tempo (read (nth (setq cnt (1+ cnt)) ss_set)))
                       (ssget "_x" (list (cons 8 layername))))
         )
   )

 

Of course you need to update the Layer list and Variable name to your needs

 

 

Merry Xmas To ALLL!!! :)

Posted

Or maybe:

 [b][color=BLACK]([/color][/b]setq i 1[b][color=BLACK])[/color][/b]
 [b][color=BLACK]([/color][/b]repeat 4
   [b][color=FUCHSIA]([/color][/b]set [b][color=NAVY]([/color][/b]read [b][color=MAROON]([/color][/b]strcat [color=#2f4f4f]"SS"[/color] [b][color=GREEN]([/color][/b]itoa i[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]ssget [color=#2f4f4f]"X"[/color] [b][color=MAROON]([/color][/b]list [b][color=GREEN]([/color][/b]cons 8 [b][color=BLUE]([/color][/b]strcat [color=#2f4f4f]"LAYER"[/color] [b][color=RED]([/color][/b]itoa i[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
   [b][color=FUCHSIA]([/color][/b]setq i [b][color=NAVY]([/color][/b]1+ i[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

 

 

-David

Posted
Or maybe:

[b][color=BLACK]([/color][/b]setq i 1[b][color=BLACK])[/color][/b]
[b][color=BLACK]([/color][/b]repeat 4
[b][color=FUCHSIA]([/color][/b]set [b][color=NAVY]([/color][/b]read [b][color=MAROON]([/color][/b]strcat [color=#2f4f4f]"SS"[/color] [b][color=GREEN]([/color][/b]itoa i[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
[b][color=NAVY]([/color][/b]ssget [color=#2f4f4f]"X"[/color] [b][color=MAROON]([/color][/b]list [b][color=GREEN]([/color][/b]cons 8 [b][color=BLUE]([/color][/b]strcat [color=#2f4f4f]"LAYER"[/color] [b][color=RED]([/color][/b]itoa i[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
[b][color=FUCHSIA]([/color][/b]setq i [b][color=NAVY]([/color][/b]1+ i[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

 

-David

 

Yup. I agree. that will eliminate the need for the list. but then again. if you have different layers with different name.. you may still need to make a list for layers

 

Good point David

Posted

I use something similar to this a lot for detailing assemblies:

[color=#8b4513];;;GET LAYER NUMBERS[/color]
 [b][color=BLACK]([/color][/b]while
   [b][color=FUCHSIA]([/color][/b]progn
       [b][color=NAVY]([/color][/b]and il [b][color=MAROON]([/color][/b]princ [color=#2f4f4f]"\n"[/color][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]prin1 il[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
       [b][color=NAVY]([/color][/b]setq in [b][color=MAROON]([/color][/b]getint [color=#2f4f4f]"\nLayer Number To Select:   "[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
   [b][color=FUCHSIA]([/color][/b]if [b][color=NAVY]([/color][/b]and in [b][color=MAROON]([/color][/b]not [b][color=GREEN]([/color][/b]member in il[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
       [b][color=NAVY]([/color][/b]setq il [b][color=MAROON]([/color][/b]cons in il[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

[color=#8b4513];;;GET PICK SETS[/color]
 [b][color=BLACK]([/color][/b]foreach i il
   [b][color=FUCHSIA]([/color][/b]setq dxs [b][color=NAVY]([/color][/b]strcat [color=#2f4f4f]"SS"[/color] [b][color=MAROON]([/color][/b]if [b][color=GREEN]([/color][/b]< i 10[b][color=GREEN])[/color][/b] [color=#2f4f4f]"0"[/color] [color=#2f4f4f]""[/color][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]itoa i[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
   [b][color=FUCHSIA]([/color][/b]set [b][color=NAVY]([/color][/b]read dxs[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]ssget [color=#2f4f4f]"X"[/color] [b][color=MAROON]([/color][/b]list [b][color=GREEN]([/color][/b]cons 8  [b][color=BLUE]([/color][/b]strcat [color=#2f4f4f]"LAYER"[/color] [b][color=RED]([/color][/b]itoa i[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

 

-David

Posted

I think the OP requested that a window be selected hence I would opt for Alan's demonstration.

 

I wouldn't approach it in the way my code illustrates, however it does show a way to assign the variables as the OP originally requests:

 

(defun c:test ( / ss ) (vl-load-com)
 
 (if (setq ss (ssget (setq l '((8 . "Layer1,Layer2,Layer3,Layer4")))))
   (
     (lambda ( l / i e sym )
       (repeat (setq i (sslength ss))
         (ssadd (setq e (ssname ss (setq i (1- i))))
           (cond
             (
               (eval
                 (setq sym
                   (read
                     (strcat "ss"
                       (
                         (lambda ( j )
                           (vl-some
                             (function
                               (lambda ( x ) (setq j (1+ j))
                                 (if (wcmatch (strcase (cdr (assoc 8 (entget e)))) (strcase x))
                                   (itoa j)
                                 )
                               )
                             )
                             l
                           )
                         )
                         0
                       )
                     )
                   )
                 )
               )
             )
             ( (set sym (ssadd)) )
           )
         )
       )
     )
     (LM:str->lst (cdar l) ",")
   )
 )
)

;;-------------------=={ String to List }==-------------------;;
;;                                                            ;;
;;  Separates a string into a list of strings using a         ;;
;;  specified delimiter string                                ;;
;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright © 2010 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;
;;  Arguments:                                                ;;
;;  str - string to process                                   ;;
;;  del - delimiter by which to separate the string           ;;
;;------------------------------------------------------------;;
;;  Returns:  A list of strings                               ;;
;;------------------------------------------------------------;;

(defun LM:str->lst ( str del / pos ) (vl-load-com)
 ;; © Lee Mac 2010
 (if (setq pos (vl-string-search del str))
   (cons (substr str 1 pos) (LM:str->lst (substr str (+ pos 1 (strlen del))) del))
   (list str)
 )
)

            

 

Coded more for academia than anything else - it reminds me of setting variables for every list item...

Posted

Lee,

 

Sometimes I think you must have won a lottery of parenthesis, your prize was an unlimited number one can use in their lifetime. Nest 'til you drop kinda thing! It's fun to watch, a ***** to decode. -David

Posted
Sometimes I think you must have won a lottery of parenthesis, your prize was an unlimited number one can use in their lifetime. Nest 'til you drop kinda thing! It's fun to watch, a ***** to decode. -David

 

:lol: Spices things up a bit :twisted:

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