PDA

View Full Version : Edit Multiple Blocks (color) at once?



TimZilla
20th Apr 2010, 08:29 pm
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.

WtaDude0822
21st Apr 2010, 03:20 pm
Redefine the block with the color you need. Autocad will ask you if you want to update the current block definitions in the drawing.

dbroada
21st Apr 2010, 03:37 pm
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.

TimZilla
21st Apr 2010, 04:21 pm
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.

dbroada
21st Apr 2010, 04:28 pm
in that case to answer your original question, I think programatically is about the only way.

BIGAL
22nd Apr 2010, 03:46 am
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)

TimZilla
27th Apr 2010, 01:25 pm
This is wonderful BigAL, hopefully it works.

TimZilla
27th Apr 2010, 01:37 pm
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

Geobuilder
27th Apr 2010, 04:44 pm
Another program for normalizing blocks the current drawing (http://forum.dwg.ru/showthread.php?t=21492)


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 <1 - Exit Program


(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)

tasos85
18th Nov 2012, 07:17 pm
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

nod684
19th Nov 2012, 01:51 am
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

rbracken
25th Apr 2014, 12:32 pm
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!

SLW210
28th Apr 2014, 01:15 pm
If they are not visible in paper space, check that the Layer is not frozen per viewport.

KFesting
6th May 2014, 03:29 am
Hi TimZilla,

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

Bhull1985
6th May 2014, 12:20 pm
You can use the command (load "yourlisp.lsp")
and/or you can drag/drop lisp files into the cad window to load them