Jump to content

turn off layer except selected


au-s

Recommended Posts

Hi!

 

First of all, I dont want to use LAYISO here. That is cause I need to set the settings to turn off layers ... some users may have it set to lock maybe.

 

Anyways...

 

Here is my lisp that picks entities and when they are picked all but picked turns off.

When I pick them I dont see on the screen that they are marked as picked. Only in command line I see what object are picked.

How can I modify it to show me picked entities as picked.

 

(defun c:off_layEXC ()
 (setvar "cmdecho" 0)
 (setq ent nil
lista nil
typ_ent nil
lager nil
typ_lager nil
namn nil
nr_lista nil
namn_lista
 nil
 )
 (setq ent T)
 (setvar "clayer" "0")
 (while (/= ent nil)
   (setq ent (car (entsel "\nChoose object: ")))
   (if ent
     (progn
(setq typ_lager (cdr (assoc 8 (entget ent))))
(prompt (strcat " Layer " typ_lager " chosen"))
(setq lista (append lista (list typ_lager)))
     )
     (setq ent nil)
   )
 )
 (setvar "clayer" (nth 0 lista))
 (command "_layer" "off" "*" "n" "")
 (setq nr 1)
 (while (< nr (length lista))
   (command "_layer" "on" (nth nr lista) "")
   (setq nr (1+ nr))
 )
 (princ)
)

Link to comment
Share on other sites

I'm not sure about I understanf your goal

Try this edited version, you can see the way how to

select entities with grips, another piece of code

you could be edit by youself :)

 

(defun c:off_layEXC (/ en ent lista nr typ_lager ss)
 (setvar "cmdecho" 0)
 (setq ss (ssadd))
 (setq ent T)
 (setvar "clayer" "0");--> do you need restore this setting after?
 (while (/= ent nil)
   (setq ent (entsel "\nChoose object: "))
   (if ent
     (progn
(setq en (car ent))

(setq typ_lager (cdr (assoc 8 (entget en))))
 (ssadd en ss)
(sssetfirst nil ss)
(prompt (strcat " Layer " typ_lager " chosen"))
(if (not (member typ_lager lista)); to avoid to put duplicate layer name into layer name list
(setq lista (append lista (list typ_lager))))
     )
     )
   )
(setq ent nil)
 (setvar "clayer" (nth 0 lista))
 (command "_layer" "off" "*" "n" "")
 (alert "Rest code block goes here")
 (setq nr 1)
 (while (< nr (length lista))
   (command "_layer" "on" (nth nr lista) "")
   (setq nr (1+ nr))
 )
 (setvar "cmdecho" 1)
 (princ)
)

 

~'J'~

Link to comment
Share on other sites

Or maybe something like this? -David

[b][color=BLACK]([/color][/b]defun c:offelay [b][color=FUCHSIA]([/color][/b]/ ss i ll en ln ls[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]setvar [color=#2f4f4f]"HIGHLIGHT"[/color] 1[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]not ss[b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]princ [color=#2f4f4f]"\Select Entities To Show..."[/color][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget [b][color=GREEN]([/color][/b]list [b][color=BLUE]([/color][/b]if [b][color=RED]([/color][/b]getvar [color=#2f4f4f]"CTAB"[/color][b][color=RED])[/color][/b]
                                  [b][color=RED]([/color][/b]cons 410 [b][color=PURPLE]([/color][/b]getvar [color=#2f4f4f]"CTAB"[/color][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b]
                                  [b][color=RED]([/color][/b]cons 67 [b][color=PURPLE]([/color][/b]- 1 [b][color=TEAL]([/color][/b]getvar [color=#2f4f4f]"TILEMODE"[/color][b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b][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]sslength ss[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]setq ll [b][color=NAVY]([/color][/b]list [b][color=MAROON]([/color][/b]getvar [color=#2f4f4f]"CLAYER"[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]not [b][color=MAROON]([/color][/b]minusp [b][color=GREEN]([/color][/b]setq i [b][color=BLUE]([/color][/b]1- i[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]setq en [b][color=MAROON]([/color][/b]ssname ss i[b][color=MAROON])[/color][/b]
              ln [b][color=MAROON]([/color][/b]cdr [b][color=GREEN]([/color][/b]assoc 8 [b][color=BLUE]([/color][/b]entget en[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]if [b][color=MAROON]([/color][/b]not [b][color=GREEN]([/color][/b]member ln ll[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
            [b][color=MAROON]([/color][/b]setq ll [b][color=GREEN]([/color][/b]cons ln ll[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 ls [color=#2f4f4f]""[/color][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]foreach l ll [b][color=NAVY]([/color][/b]setq ls [b][color=MAROON]([/color][/b]strcat ls l [color=#2f4f4f]","[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]command [color=#2f4f4f]"_.LAYER"[/color] [color=#2f4f4f]"_OFF"[/color] [b][color=NAVY]([/color][/b]strcat [color=#2f4f4f]"~"[/color] [b][color=MAROON]([/color][/b]getvar [color=#2f4f4f]"CLAYER"[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [color=#2f4f4f]"_ON"[/color] ls [color=#2f4f4f]""[/color][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

Link to comment
Share on other sites

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