;;; Change Color of All Layers to user defined color with change color Color of ALL entities in the drawing to ByLayer
;;; Main routine Created by Igal Averbuh 2017
;;; Subroutine AllColorBylayer.lsp created by Kent Cooper

;; AllColorBylayer.lsp [command name: ACB]
;; To change the Color of ALL entities in the drawing, including those nested in
;; Block definitions [but not Xrefs] and Dimension/Leader parts, to ByLayer.
;; Kent Cooper, 27 February 2014, expanding on some elements by p_mcknight

(defun C:ACB ; = All to Color Bylayer
(/ cb ent obj blk subent)
(defun cb () ; = force Color(s) to Bylayer
(setq obj (vlax-ename->vla-object ent))
(vla-put-color obj 256); ByLayer
(if (wcmatch (vla-get-ObjectName obj) "*Dimension,*Leader")
(foreach prop '(DimensionLineColor ExtensionLineColor TextColor)
;; not all such entity types have all 3 properties, but all have at least one
(if (vlax-property-available-p obj prop)
(vlax-put obj prop 256); ByLayer
); if
); foreach
); if
); defun -- cb
;; Top-level entities:
(setq ent (entnext))
(while ent
(setq ent (entnext ent))
); while
;; Nested entities in this drawing's Block definitions:
(setq blk (tblnext "block" t))
(while blk
(if (= (logand 20 (cdr (assoc 70 blk))) 0); not an Xref [4] or Xref-dependent [16]
(setq ent (cdr (assoc -2 blk)))
(while ent
(setq ent (entnext ent))
); while
); progn
); if
(setq blk (tblnext "block"))
); while

); defun

(defun c:cch1 (/ c1 c2 )
(setq c2 (getint " What is the new color: "))
(vlax-for layer
(vlax-get-Acad-Object))) (vla-put-Color layer c2))

(defun c:cch (/ )