View Full Version : Color of Blocks
WannaBeCader
14th Dec 2004, 04:52 am
Does anyone know of a way to force the color of a block to change?
I'm not sure if the land developer is smarter than I or not , but re- defining the block was not feasible. They blocked/mirrored buildings in sets of 3 with door/window jambs and door swings with the arc forced a color red, which show as a thick blobs when I X-ref the rest of the dwg as color 252 (Light gray). Exploding produced multiple buildings out of the blue....Tracing all the buildings in the area was more work than necessary just to force a color. Please help so tomorrow is not like today
:)
Fantomas
14th Dec 2004, 09:27 am
Try this:
(defun c:btz (/
opMode
Block
vlaList
actDoc
layerState
LayerCol
nameList
layList
blockCol
blSet
)
;;;+++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++
;;; +
;;; When entities from which consist the block not in a layer "0" +
;;; or have no color "By Block " it is impossible +
;;; to change color of the block without use of command REFEDIT. +
;;; This program can "repair" simultaneously several blocks then +
;;; it is possible to change their color. Options By Layer, By Block +
;;; and Current define color of blocks after work of the program. +
;;; +
;;; Type BTZ in command line to run. +
;;; +
;;; Supported AutoCAD Versions: AutoCAD 2000/2005 +
;;; +
;;; Writen by Fantomas (Alexander Smirnov) asmirnov@inbox.lv +
;;; +
;;; Version 1.0 Nov 01, 2004 +
;;; +
;;;+++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++
(vl-load-com)
(initget "L B C")
(setq opMode
(getkword "\nSelect output block(s) color [byLayer/byBlock/Current]<L>: "))
(if(null opMode)(setq opMode "L"))
(princ "\nSelect block(s) and press Enter ")
(setq blSet(ssget '((0 . "INSERT"))))
(if blSet
(progn
(setq actDoc(vla-get-ActiveDocument
(vlax-get-acad-object))
LayerCol(vla-get-Layers actDoc)
layerState '()
vlaList(mapcar 'vlax-ename->vla-object
(vl-remove-if 'listp
(mapcar 'cadr(ssnamex blSet))))
nameList
(mapcar
'(lambda (x)(vla-get-Name x))vlaList)
layList
(mapcar '(lambda(x)
(list x(vla-get-Layer x)(vla-get-Color x)))vlaList)
blockCol
(vla-get-blocks actDoc)
); end setq
(vlax-for l LayerCol
(setq layerState
(append layerState
(list
(list
l
(vla-get-Lock l)))))
(vla-put-lock l :vlax-false)
); end vlax-for
(vlax-for i blockCol
(vlax-for e i
(if
(member (vla-get-Name i)nameList)
(progn
(vla-put-Layer e "0")
(vla-put-Color e 0)
); end progn
); end if
); end vlax-for
); end vlax-for
(foreach i layList
(vla-put-Layer(car i)(cadr i))
(cond
((= opMode "L")(vla-put-Color(car i)256))
((= opMode "B")(vla-put-Color(car i)0))
((= opMode "C")(vla-put-Color(car i)(nth 2 i)))
); end cond
); end foreach
(foreach l layerState
(vla-put-Lock (car l)(cadr l))
); end foreach
); end progn
(princ "\nNothing block(s) selected!")
); end if
(vla-regen actDoc acAllViewports)
(princ)
); end of btz
(princ "Type BTZ to Run")
Powered by vBulletin™ Version 4.1.2 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.