Jump to content
TimZilla

Edit Multiple Blocks (color) at once?

Recommended Posts

TimZilla

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.

Share this post


Link to post
Share on other sites
WtaDude0822

Redefine the block with the color you need. Autocad will ask you if you want to update the current block definitions in the drawing.

Share this post


Link to post
Share on other sites
dbroada

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.

Share this post


Link to post
Share on other sites
TimZilla
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.

Share this post


Link to post
Share on other sites
dbroada

in that case to answer your original question, I think programatically is about the only way.

Share this post


Link to post
Share on other sites
BIGAL

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) 

Share this post


Link to post
Share on other sites
TimZilla

This is wonderful BigAL, hopefully it works.

Share this post


Link to post
Share on other sites
TimZilla

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

Share this post


Link to post
Share on other sites
BearDyugin

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

Share this post


Link to post
Share on other sites
tasos85

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

 

Share this post


Link to post
Share on other sites
nod684
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

Share this post


Link to post
Share on other sites
rbracken

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!

Share this post


Link to post
Share on other sites
SLW210

If they are not visible in paper space, check that the Layer is not frozen per viewport.

Share this post


Link to post
Share on other sites
KFesting

Hi TimZilla,

 

Just wondering how you used this one? I've created the lisps' for them but do you execute them one after another?

Share this post


Link to post
Share on other sites
Bhull1985

You can use the command (load "yourlisp.lsp")

and/or you can drag/drop lisp files into the cad window to load them

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×