changing layer shortcut

changing layer shortcut

Anonymous
Not applicable
15,635 Views
10 Replies
Message 1 of 11

changing layer shortcut

Anonymous
Not applicable

Hello,

I have been spending a lot of time today researching methods to increase productivity and efficiency and I came across a command ('_-LAYER;_Set;mylayer1;;) to set current layer and put our most used to ctrl+1, ctrl+2... etc. This is super helpful, but I am curious about if there is a command to mimic the action of selecting the a layer from the drop down menu. The way it functions, of course, is when there is no objects selected, it will switch the current layer; when there is any objects selected it will change the layer property of the object(s). I want a command that will do this. Anyone know a replacement command?

 

Thank you!

Michael

0 Likes
Accepted solutions (1)
15,636 Views
10 Replies
Replies (10)
Message 2 of 11

s.borello
Advisor
Advisor

Are you looking for the "laymakecurrent" command? 

0 Likes
Message 3 of 11

ВeekeeCZ
Consultant
Consultant
Accepted solution

Try this LISP as your macro... unless you don't run LT...

(if (ssget "_I") (command "_chprop" "_layer" "mylayer" "") (command "_layer" "_m" "mylayer" ""))

 

0 Likes
Message 4 of 11

leothebuilder
Advisor
Advisor

You can save this to a lisp file and place in it in the start-up suite.

Command LL will allow to to select an object and set that layer current.

Command CUR will allow you to change objects to the current layer.

I've used these commands for over 20 years and couldn't live without.

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(DEFUN C:LL (/ e n)
(setq e (car (entsel "\nTo which would like the layer set..:")))
(if e
(progn
(setq e (entget e))
(setq n (cdr (assoc 8 e)))
(COMMAND "LAYER" "S" n "")
)
)
(princ (strcat "\nI'll be doggone,.... you did it!!!: "n))
(princ)
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; THE FOLLOWING LISP WILL CHANGE A SELECTED ENTITY TO THE CURRENT LAYER.
(DEFUN C:CUR (/ SS DL)
(setq e (car (entsel "\nPick entities you want changed to the current layer !!:")))
(setvar "cmdecho" 0)
(SETQ SS (SSGET))
(SETQ DL (GETVAR "CLAYER"))
(COMMAND ".CHPROP" SS "" "LA" DL"" )
(PROMPT "Cool, Entities changed to current layer ")
(EVAL DL)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

0 Likes
Message 5 of 11

Moshe-A
Mentor
Mentor

@Anonymous  hi,

 

post your most used layer list cause i have a beautiful solution for you.

 

moshe

 

 

 

 

0 Likes
Message 6 of 11

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... when there is no objects selected, it will switch the current layer; when there is any objects selected it will change the layer property of the object(s). ….


 

Here's what I use for exactly that in relation to Layer 0.  You can make others and substitute any other Layer name.

(defun C:L0 ()
  ; put pre-selected object(s) [if any] on Layer 0, otherwise set current Layer to 0
  (if (ssget "_I")
    (command "_.chprop" "_layer" "0" ""); then
    (command "_.layer" "_thaw" "0" "_set" "0" ""); else
  ); if
  (princ)
)

[EDITED -- the first version was written for an older version, but doesn't work right in newer ones, and this is now the same as @ВeekeeCZ's version, except that mine will not have a problem if the Layer exists but is frozen.]  Since Layer 0 always exists, this doesn't need to account for it possibly not existing.  For other Layer names, you could substitute "_make" in place of "_set" in the second (command), but for the first one, more would need to be done.  If that's needed, a question arises:  Would you want it to merely put the selected objects on that Layer without making that Layer current, or would you also want it made current?

 

FURTHER EDIT:  It occurs to me that rather than defining separate commands  for each Layer you might want to do this with, you can define a function  with an argument:

 

(defun dolayer (layname)
  ; put pre-selected object(s) [if any] on specified Layer, otherwise set that Layer current
  (if (ssget "_I")
    (command "_.chprop" "_layer" layname ""); then
    (command "_.layer" "_thaw" layname "_set" layname ""); else
  ); if
  (princ)
)

That way, you can put simpler entries into Tool Palette items, or other menu items:

(dolayer "0"); equivalent to my first routine above

(dolayer "GeorgeClooney")

(dolayer "MarieAntoinette")

 

Kent Cooper, AIA
0 Likes
Message 7 of 11

Anonymous
Not applicable

Hello,

Thanks again for the great macro(or LISP?)! I'm wondering if you can help me add to it the function to keep the selection after completing the command. For example: selecting some objects, activating the command to change their layer and the objects stay selected. This would be real handy.

 

Thanks!

Michael

0 Likes
Message 8 of 11

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... add to it the function to keep the selection after completing the command. ....


 

Basing it on my variant:

(defun C:LTheLayerName (/ ss)
  ; put pre-selected object(s) [if any] on Layer and highlight, otherwise set current
  (if (setq ss (ssget "_I"))
(progn ; then (command "_.chprop" "_layer" "TheLayerName" "")
(sssetfirst nil ss); select/grip/highlight
); progn (command "_.layer" "_thaw" "TheLayerName" "_make" "TheLayerName" ""); else ); if (princ) )
Kent Cooper, AIA
0 Likes
Message 9 of 11

Anonymous
Not applicable

Thank you, I will try this. I didn't try your lisp, because I tried the other one first and it worked fine. Should it work when plugging into a macro like the other one? Not sure how that works.

 

Thanks,

Michael

0 Likes
Message 10 of 11

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... Should it work when plugging into a macro like the other one? Not sure how that works. ....


 

Try it!  Omit the top two lines and the bottom two lines, remove all semicolons and whatever follows one on the same line, and string the rest together.

 

Or, have it loaded as a command definition by something like acaddoc.lsp, and just put the command name in a macro button.

Kent Cooper, AIA
0 Likes
Message 11 of 11

ВeekeeCZ
Consultant
Consultant

@Anonymous wrote:

... I'm wondering if you can help me add to it the function to keep the selection after completing the command...

 

(if (ssget "_I") (progn (command "_chprop" "_layer" "mylayer" "") (sssetfirst nil (ssget "_P"))) (command "_layer" "_t"  "mylayer" "_m" "mylayer" ""))

It's basically the same as Kent suggested...

0 Likes