Here's one I use on a regular basis:
(defun c:Clone (/ ent layer name)
;; Clone selected object's layer
;; Required subroutine: AT:GetString
;; Alan J. Thompson, 02.09.11
(setvar 'ERRNO 0)
(if (while (and (not ent) (/= 52 (getvar 'ERRNO)))
(initget 0 "Current")
(setq ent (entsel "\nSelect object on layer to clone [Current]: "))
)
(cond ((not (setq name (AT:GetString
"Specity clone layer name:"
(setq layer (if (eq (type ent) 'STR)
(getvar 'CLAYER)
(cdr (assoc 8 (entget (car ent))))
)
)
)
)
)
)
((not (snvalid name)) (alert "Invalid name!"))
((apply (function eq) (mapcar (function strcase) (list name layer)))
(alert "Clone layer cannot have same name as base layer!")
)
((tblsearch "LAYER" name) (alert "Layer already exist!"))
((entmake (append
(list '(0 . "LAYER")
'(100 . "AcDbSymbolTableRecord")
'(100 . "AcDbLayerTableRecord")
(cons 2 name)
)
(vl-remove-if-not
(function (lambda (x) (vl-position (car x) '(6 62 70 270 370))))
(entget (tblobjname "LAYER" layer))
)
)
)
(alert (strcat "Layer \""
layer
"\" has been cloned to create layer: \""
(setvar 'CLAYER name)
"\""
)
)
)
)
)
(princ)
)
(defun AT:GetString (#Title #Default / #FileName #FileOpen #DclID #NewString)
;; Getstring Dialog Box
;; #Title - Title of dialog box
;; #Default - Default string within edit box
;; Alan J. Thompson, 08.25.09
(setq #FileName (vl-filename-mktemp "" "" ".dcl")
#FileOpen (open #FileName "W")
)
(foreach x '("TempEditBox : dialog {" "key = \"Title\";" "label = \"\";"
"initial_focus = \"Edit\";" "spacer;" ": row {" ": column {" "alignment = centered;"
"fixed_width = true;" ": text {" "label = \"\";" "}" "}" ": edit_box {"
"key = \"Edit\";" "allow_accept = true;" "edit_width = 40;" "fixed_width = true;" "}"
"}" "spacer;" ": row {" "fixed_width = true;" "alignment = centered;" ": ok_button {"
"width = 11;" "}" ": cancel_button {" "width = 11;" "}" "}" "}//"
)
(write-line x #FileOpen)
)
(close #FileOpen)
(setq #DclID (load_dialog #FileName))
(new_dialog "TempEditBox" #DclID)
(set_tile "Title" #Title)
(set_tile "Edit" #Default)
(action_tile "accept" "(setq #NewString (get_tile \"Edit\"))(done_dialog)")
(action_tile "cancel" "(done_dialog)")
(start_dialog)
(unload_dialog #DclID)
(vl-file-delete #FileName)
#NewString
)