Jump to content

changing blocks colors


Recommended Posts

Posted

Just got new backgrounds from a company and each door is its own block. the blocks are set by color instead of by layer. The doors are red which is the second thickest line on our ctb. is there a way to change all of them at once to a new color?

Posted

i found it. I dont know much about lisps other then how to load and execute. is there a way to change it so you can select the layer you want instead of it being put on layer 0 and also by layer insted of by block? i attached it so you dont have to go search for it.

fixblock.lsp

Posted

What you could do if its just a regular block is explode it. Then create it again but this time in Layer "0" The block will then change it attributes depending on what layer you put it in.

 

You can do the same for a dynamic block, but obviously you will have a bit more work to do to create it again.

 

Gaz...

Posted

Maybe this may be of some help

 

http://www.cadtutor.net/forum/showthread.php?t=13295&highlight=block

 

There should be a few more LISP routines posted already in this site

 

This is a very useful routine posted by kpblc, unfortunately I can't find the original thread

 

Author kpblc 

(defun c:norm (/ *error* adoc lst_layer func_restore-layers)
 (defun *error* (msg)
   (func_restore-layers)
   (vla-endundomark adoc)
   (princ msg)
   (princ)
   ) ;_ end of defun

 (defun func_restore-layers ()
   (foreach item lst_layer
     (vla-put-lock (car item) (cdr (assoc "lock" (cdr item))))
     (vl-catch-all-apply
       '(lambda ()
          (vla-put-freeze (car item) (cdr (assoc "freeze" (cdr item))))
          ) ;_ end of lambda
       ) ;_ end of vl-catch-all-apply
     ) ;_ end of foreach
   ) ;_ end of defun

 (vl-load-com)
 (vla-startundomark
   (setq adoc (vla-get-activedocument (vlax-get-acad-object)))
   ) ;_ end of vla-startundomark
 (vlax-for item (vla-get-layers adoc)
   (setq lst_layer (cons (list item
                               (cons "lock" (vla-get-lock item))
                               (cons "freeze" (vla-get-freeze item))
                               ) ;_ end of list
                         lst_layer
                         ) ;_ end of cons
         ) ;_ end of setq
   (vla-put-lock item :vlax-false)
   (vl-catch-all-apply '(lambda () (vla-put-freeze item :vlax-false)))
   ) ;_ end of vlax-for
 (vlax-for blk (vla-get-blocks adoc)
   (if (and (equal (vla-get-islayout blk) :vlax-false)
            (equal (vla-get-isxref blk) :vlax-false)
            ) ;_ end of and
     (progn
       (vlax-for subent blk
          [color="Red"];(vla-put-layer subent "0");edit-> removed force to layer 0[/color]
         (vla-put-color subent 256)
         (vla-put-lineweight subent aclnwtbyblock)
         (vla-put-linetype subent "byblock")
         ) ;_ end of vlax-for
       ) ;_ end of progn
     ) ;_ end of if
   ) ;_ end of vlax-for
 (func_restore-layers)
 (vla-endundomark adoc)
 (princ)
 ) ;_ end of defun

 

Routine will change all inserted blocks in a drawing to bylayer

 

Regards,

 

Jammie

Posted

Jammie, that worked great. Thanks

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