(defun c:inr (/ colLst lay col) ; change layer colours siutable for INR
(vl-load-com)

(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
(c:acb)
(layerstate-save "before-inr-change" nil nil)
(setq colLst '(
(7 . 1)
(14 . 27)
(24 . 27)
(20 . 30)
(22 . 27)
(70 . 102)
(74 . 107)
(72 . 102)
(3 . 102)
(90 . 102)
(92 . 102)
(161 . 160)
(151 . 160)
(154 . 160)
(165 . 162)
(140 . 162)
(142 . 162)
(2 . 1)
(50 . 1)
(55 . 107)
(57 . 107)
(75 . 107)
(40 . 27)
(42 . 27)
(155 . 175)
(156 . 175)
(22 . 27)
(10 . 27)
(211 . 27)
(232 . 27)
(13 . 27)
(12 . 27)
(222 . 190)
(224 . 190)
(226 . 190)
(120 . 230)
(122 . 102)
(60 . 230)
(62 . 230)
(64 . 230)
(8 . 253)
(163 . 162)
(81 . 102)
(82 . 102)
(100 . 102)
(92 . 102)
(60 . 1)
(64 . 102)
(62 . 102)
(66 . 102)
(67 . 102)
(253 . 252)
(254 . 252)
(255 . 252)
(227 . 190)
(130 . 162)
(4 . 160)
))

(vlax-for l (vla-get-layers
(vla-get-activedocument
(vlax-get-acad-object)))
(setq lay (cons l lay)))
(foreach layer lay
(if (setq col (assoc (vla-get-color layer) colLst))
(vla-put-color layer (cdr col))))
(princ))

(defun c:rinr (/) ; restore inr layer colours
(vl-load-com)
(layerstate-restore "before-inr-change" nil nil)
)

Advertisements