TimZilla Posted April 20, 2010 Posted April 20, 2010 Let's say I have a whole bunch of blocks, and they are all different colors. I want to make them all one color without having to go into the block editor screen for each one. there has to be a way. Quote
WtaDude0822 Posted April 21, 2010 Posted April 21, 2010 Redefine the block with the color you need. Autocad will ask you if you want to update the current block definitions in the drawing. Quote
dbroada Posted April 21, 2010 Posted April 21, 2010 This really does come down to doing it right in the first place. You should only define colours & layers in blocks if you REALLY need to. It is far better to create your geometry on Layer 0 and use colour byLayer or byBlock. That way all you need do is put your blocks on a different layer or assign them a different clour and its all done. Quote
TimZilla Posted April 21, 2010 Author Posted April 21, 2010 This really does come down to doing it right in the first place. You should only define colours & layers in blocks if you REALLY need to. It is far better to create your geometry on Layer 0 and use colour byLayer or byBlock. That way all you need do is put your blocks on a different layer or assign them a different clour and its all done. Well, I have to put other peoples plans into my drawing. For instance the HVAC, machanical drawings. Those guys use about 20 different colors, and everything is a block. I like making all the other trades stuff a certain color and lock it. That way when I draw my piping I can focus. If everyone did like you say, it would work just fine. Quote
dbroada Posted April 21, 2010 Posted April 21, 2010 in that case to answer your original question, I think programatically is about the only way. Quote
BIGAL Posted April 22, 2010 Posted April 22, 2010 You can edit a block and change all the stuff inside heres a lisp about changing the line type in every block where a particular line type was found to a different one. I got the source from the forum here its called block edit ; my line only change ;(defun c:normblocks (/ adoc) (vl-load-com) (setq adoc (vla-get-activedocument (vlax-get-acad-object))) (vla-startundomark adoc) (vlax-for block (vla-get-blocks adoc) (if (not (wcmatch (strcase (vla-get-name block) t) "*_space*")) (vlax-for ent block (if (= (vla-get-linetype ent ) "solid" ) (progn (vla-put-linetype ent "Continuous") (princ (vla-get-name block)) ) );_ end of if ) ;_ end of vlax-for ) ;_ end of if ) ;_ end of vlax-for (vla-regen adoc acactiveviewport) (vla-endundomark adoc) (princ) complete code should be easy to change color (defun c:normblocks (/ adoc) (vl-load-com) (setq adoc (vla-get-activedocument (vlax-get-acad-object))) (vla-startundomark adoc) (vlax-for block (vla-get-blocks adoc) (if (not (wcmatch (strcase (vla-get-name block) t) "*_space*")) (vlax-for ent block ; (vla-put-color ent 0) (vla-put-linetype ent "Bylayer") (vla-put-lineweight ent aclnwtbyblock) ) ;_ end of vlax-for ) ;_ end of if ) ;_ end of vlax-for (vla-regen adoc acactiveviewport) (vla-endundomark adoc) (princ) ) ;_ end of defun (defun c:normblock (/ adoc selset) (vl-load-com) (setq adoc (vla-get-activedocument (vlax-get-acad-object))) (vla-startundomark adoc) (if (setq selset (ssget "_:S:L" '((0 . "INSERT")))) (vlax-for ent (vla-item (vla-get-blocks adoc) (cdr (assoc 2 (entget (ssname selset 0)))) ) ;_ end of vla-item (vla-put-color ent 0) (vla-put-linetype ent "ByBlock") (vla-put-lineweight ent aclnwtbyblock) ) ;_ end of vlax-for ) ;_ end of if (vla-endundomark adoc) (princ) ) ;_ end of defun found color by layer (vl-load-com) (setq adoc (vla-get-activedocument (vlax-get-acad-object))) (vla-startundomark adoc) (vlax-for block (vla-get-blocks adoc) (if (not (wcmatch (strcase (vla-get-name block) t) "*_space*")) (vlax-for ent block (vla-put-color ent 0) (vla-put-linetype ent "Bylayer") (vla-put-lineweight ent aclnwtbyblock) ) ;_ end of vlax-for ) ;_ end of if ) ;_ end of vlax-for (vla-regen adoc acactiveviewport) (vla-endundomark adoc) (princ) Quote
TimZilla Posted April 27, 2010 Author Posted April 27, 2010 This is wonderful BigAL, hopefully it works. Quote
TimZilla Posted April 27, 2010 Author Posted April 27, 2010 wow, I made all of these a Lisp file, loaded them into CAD. AND BOOM! I can change ever single block to what ever color I want! simply by clicking on it and changing the color! I do not have to go into the block edit! just load, and it automatically makes every block perfect. this is going to save me so much time BigAL. Just wanted to let you know you made somebody's life easier. Wow, I feel like I can take longer breaks now! Coffee? sounds good to me Quote
BearDyugin Posted April 27, 2010 Posted April 27, 2010 Another program for normalizing blocks the current drawing Example call: (Norm-blocks bit) Invocation Arguments: bit sum of any number of the following values: 1; layer of the object - "0" 2, line type of object - ByBlock 4, line weight of the object - ByBlock 8, line color object - ByBlock 16; scale line object - 1 nil or (Norm-blocks 1); transfer all objects of all the blocks in the layer "0", without changing other settings (Norm-blocks 2); change the type of lines of all objects of all the blocks on the "ByBlock", without changing other properties (Norm-blocks 7); change the layer to "0" (1), the type of coils - at ByBlock (2); weight line - at ByBlock (4) norm-blocks.lsp Quote
tasos85 Posted November 18, 2012 Posted November 18, 2012 Can you please explain how to load the lisp file, i don't know how to use lisps:(. I have many blocks I want changed to the same color and cannot do it otherwise You can edit a block and change all the stuff inside heres a lisp about changing the line type in every block where a particular line type was found to a different one. I got the source from the forum here its called block edit complete code should be easy to change color (defun c:normblocks (/ adoc) (vl-load-com) (setq adoc (vla-get-activedocument (vlax-get-acad-object))) (vla-startundomark adoc) (vlax-for block (vla-get-blocks adoc) (if (not (wcmatch (strcase (vla-get-name block) t) "*_space*")) (vlax-for ent block ; (vla-put-color ent 0) (vla-put-linetype ent "Bylayer") (vla-put-lineweight ent aclnwtbyblock) ) ;_ end of vlax-for ) ;_ end of if ) ;_ end of vlax-for (vla-regen adoc acactiveviewport) (vla-endundomark adoc) (princ) ) ;_ end of defun (defun c:normblock (/ adoc selset) (vl-load-com) (setq adoc (vla-get-activedocument (vlax-get-acad-object))) (vla-startundomark adoc) (if (setq selset (ssget "_:S:L" '((0 . "INSERT")))) (vlax-for ent (vla-item (vla-get-blocks adoc) (cdr (assoc 2 (entget (ssname selset 0)))) ) ;_ end of vla-item (vla-put-color ent 0) (vla-put-linetype ent "ByBlock") (vla-put-lineweight ent aclnwtbyblock) ) ;_ end of vlax-for ) ;_ end of if (vla-endundomark adoc) (princ) ) ;_ end of defun Quote
nod684 Posted November 19, 2012 Posted November 19, 2012 Can you please explain how to load the lisp file, i don't know how to use lisps:(. I have many blocks I want changed to the same color and cannot do it otherwise Copy the code that Bigal sent you. Paste it in notepad and save it with .lsp as an extension in AutoCAD, type Appload browse for the lisp file once found, click load then close then type normblocks at the command line Quote
rbracken Posted April 25, 2014 Posted April 25, 2014 This thread has really helped. Had a lot of blocks to edit. Is there are a way to revert the blocks back to original colours? Also the blocks are no longer visible in paperspace. Is there a reason for this? I am a novice user and currently on trial at a new job, so any advice would be great! Quote
SLW210 Posted April 28, 2014 Posted April 28, 2014 If they are not visible in paper space, check that the Layer is not frozen per viewport. Quote
KFesting Posted May 6, 2014 Posted May 6, 2014 Hi TimZilla, Just wondering how you used this one? I've created the lisps' for them but do you execute them one after another? Quote
Bhull1985 Posted May 6, 2014 Posted May 6, 2014 You can use the command (load "yourlisp.lsp") and/or you can drag/drop lisp files into the cad window to load them Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.