Maybe you can use variants of this routine:
(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)
)
If there are any pre-selected objects, it puts them on Layer 0 [you can substitute a different Layer name, and make such a command for any Layer(s) you need]. If there are no pre-selected objects, it sets Layer 0 current. [It does not account for possible locked Layers, but they would not cause an error -- they just won't be changed.]
Or, maybe you can use something like this, which is to put things on the current Layer:
;| ToCurrentLayer.lsp [command name: TCL]
Moves selected objects to current layer.
Kent Cooper, last edited 29 Jan 2021 to allow pre-selection
|;
(defun C:TCL (); = To Current Layer
(command "_.chprop"
(cond
((ssget "_I") (ssget "_:L-I")); unlocked only among pre-selection if any
((ssget "_:L")); otherwise, unlocked only among new selection
); cond
"" "_layer" (getvar 'clayer) ""
); command
(princ)
); defun
If there are any pre-selected objects, it moves them [any of them not on locked Layers, that is] to the current Layer. If not, it asks the User to select objects [again forbidding those on locked Layers], and moves them to the current Layer.
But I agree with the question -- is the only reason for changing the current Layer to move things to it? It's not necessary to do it that way, but you can just put things on that Layer without making it current, as the L0 command above does if there's a pre-selection.
Kent Cooper, AIA