That would be an easy thing to write a routine to do, but with one object selected [or multiple objects if they're all on the same Layer] the Layer panel in the ribbon shows you directly:
Does that not tell you what you want to know? I keep the Properties palette up all the time, narrowed down along one side of the screen, and it also shows the Layer of what is selected [again, when more than one object, if they are all on the same Layer].
test it
(setq ent (car (entsel "\n Pick the Obj" )))
(setq ent-name (Cdr (assoc 0 (entget ent))))
(setq ent-layer (Cdr (assoc 8 (entget ent))))
(alert (strcat "\n the object is a: " ent-name "\n on layer" ent-layer))
@jaimuthu wrote:
.... i select object and get layer name in msgbox
In very simplest terms, if literally just that much will do:
(alert (cdr (assoc 8 (entget (car (entsel))))))
You can just paste that in at the command line, or put just that into a Tool Palette button, or with a little bit of additional code, define it into a command name that you can type in.