Code:(vl-load-com) ;;;changes entities from layer whose color is 251 to specified layer (defun c:ElecChngLayByColor (/ acadobject activedocument LayerTable thelist clc klay_name i aObj) ;;;Creates a layer for entities to be moved to (command "-layer" "m" "background" "c" "6" "background" "") ;_ end command (setq acadobject (vlax-get-Acad-Object)) (setq activedocument (vla-get-activedocument acadobject)) (setq LayerTable (vla-get-layers activedocument)) (vlax-for each LayerTable (setq klay_name (vla-get-name each)) (setq clc (vla-get-color each)) ;;;above is VL stuff I don't fully understand but it walks through ;;;layer table and gets the color assigned to each layer ;;;if the color is 251 then the "(cond" section runs (if (= clc 251) (cond ((setq ss1 (ssget "X" (list (cons 8 klay_name)))) (repeat (setq i (sslength ss1)) (setq aObj (vlax-EName->vla-Object (ssname ss1 (setq i (1- i))))) (vla-Put-Layer aObj "Background") (vla-Put-Color aObj acByLayer)))) ) ;_ end if ) ;_ end of vlax-for (princ "That's All Folks!") (princ) );defun