;;; Beekee CZ Add Prefix to Layers of Selected objects
;;; Saved from: http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-layer-from-selected-objects-layer/td-p/6676481
(defun c:Lp ( / ss tx ed la)
(if (and (setq ss (ssget ":L"))
(setq tx (getstring T "\nText to add to Prefix of Layers: "))
(snvalid tx)
)
(repeat (setq i (sslength ss))
(setq ed (entget (ssname ss (setq i (1- i))))
la (strcat tx (cdr (assoc 8 ed))))
(or (tblsearch "layer" la)
(entmake (list '(0 . "LAYER")
'(100 . "AcDbSymbolTableRecord")
'(100 . "AcDbLayerTableRecord")
'(70 . 0)
'(62 . 2))))
(entmod (append ed (list (cons 8 la))))))
(princ)
)
(c:lp)

Advertisements