;;; 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

(vl-load-com)
;; 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
(cb)
(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]
(progn
(setq ent (cdr (assoc -2 blk)))
(while ent
(cb)
(setq ent (entnext ent))
); while
); progn
); if
(setq blk (tblnext "block"))
); while

(princ)
); defun

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

(defun c:cch (/ )
(c:acb)
(c:cch1)
)
;(c:cch)

Advertisements