Jump to content

Recommended Posts

Posted

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.

Posted

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

Posted

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.

Posted
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.

Posted

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

Posted

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) 

Posted

This is wonderful BigAL, hopefully it works.

Posted

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

Posted

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

  • 2 years later...
Posted

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

 

Posted
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

  • 1 year later...
Posted

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!

Posted

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

Posted

Hi TimZilla,

 

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

Posted

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

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

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...