How to change the color of a block?

How to change the color of a block?

Anonymous
Not applicable
684 Views
3 Replies
Message 1 of 4

How to change the color of a block?

Anonymous
Not applicable

Hi,

 

I usually don`t have any issues changing the colour of a block but on this file, I don`t manage to change it. Does anyone got an idea how to change the red to black and green to black?

 

Is there a tutorial? Also, why it doesn`t not change if we select the objects and change the property color?

 

Many thanks,

0 Likes
685 Views
3 Replies
Replies (3)
Message 2 of 4

Kent1Cooper
Consultant
Consultant

Assign the color "BYBLOCK" to all pieces within Blocks that you want to take on the color that is assigned to the Block insertion.

Kent Cooper, AIA
0 Likes
Message 3 of 4

Anonymous
Not applicable

Hi,

 

It doesn`t seem to work. Are you able to test it on the file I`ve included?

 

Many Thanks,

0 Likes
Message 4 of 4

john.uhden
Mentor
Mentor

Here is an example of what @Kent1Cooper meant.

It changes every entity within a block definition to color ByBlock, which then allows a block insertion (reference) to have its color changed, independent of layer color, which is most prevalent by AutoCAD users.

(defun C:BB ( / *error* @reset |e |e0 |ent |etyp |done |bname |ans |flag)
   ;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
   ;*                                                                           *
   ;*         BB.LSP     by     John F. Uhden                                   *
   ;*                           2 Village Road                                  *
   ;*                           Sea Girt, NJ  08750                             *
   ;*                                                                           *
   ;*                                                                           *
   ;* * * * * * * * * * * *  Do not delete this heading!  * * * * * * * * * * * *

   ; Program redefines all entities in a block definition to color BYBLOCK.

   ; v2.1 (10-24-97) corrected (redraw) and (chr 7)
   ; v15.00 (04-07-00) for R15
   ; v16.0 (02-10-2020) revised as freeware for Challoner, using R16

   (gc)
   (prompt "\nBB v16.0 (c)1994-2020, John F. Uhden")
   (prompt "\nThis routine will redefine all entities in a block to color BYBLOCK.")
   (vl-doc-set '$cv_cmdname (getvar "cmdnames"))

   (defun *error* (error)
      (mapcar 'setvar vars vals)
      (vla-endundomark *doc*)
      (cond
        (not error)
        ((wcmatch (strcase error) "*CANCEL*,*QUIT*")
          (vl-exit-with-error "\r                                              ")
        )
        (1 (vl-exit-with-error (strcat "\r*ERROR*: " error)))
      )
      (princ)
   )
   ;;------------------------------------------
   ;; Intitialze drawing and program variables:
   ;;
   (setq *acad* (vlax-get-acad-object))
   (setq *doc* (vlax-get *acad* 'ActiveDocument))
   (vla-endundomark *doc*)
   (vla-startundomark *doc*)
   (setq vars '("cmdecho" "highlight"))
   (setq vals (mapcar 'getvar vars))
   (mapcar 'setvar vars '(0 1))
   (command "_.expert" (getvar "expert")) ;; dummy command

   (if (setq |e0 (entsel "\nPick a block to redefine: "))
      (progn
         (setq |e0 (car |e0)
               |ent (entget |e0)
               |etyp (cdr (assoc 0 |ent))
               |flag (cdr (assoc 70 |ent))
         )
         (redraw |e0 3)
         (if (and (= |etyp "INSERT")(= (logand |flag 4) 4))
            (setq |etyp "Xref")
         )
         (if (= |etyp "INSERT")
            (progn
               (setq |bname (cdr (assoc 2 |ent))
                     |e (tblsearch "block" |bname)
                     |e (cdr (assoc -2 |e)) |done nil
               )
               (prompt (strcat "\nBlock name is " |bname "."))
               (initget "Yes No")
               (setq |ans (getkword "\nAre you sure you want to redefine it?  Yes/<No>: "))
               (if (= |ans "Yes")
                  (progn
                     (while (not |done)
                        (setq |ent (entget |e))
                        (if (assoc 62 |ent)
                           (setq |ent (subst (cons 62 0)(assoc 62 |ent) |ent))
                           (setq |ent (append |ent (list (cons 62 0))))
                        )
                        (entmod |ent)(entupd |e)
                        (if (not (setq |e (entnext |e)))(setq |done 1))
                     )
                     (prompt "\nDisplay will be correct after next regen.\n")
                  )
               )
            )
            (prompt (strcat "\nEntity selected is a(n) " |etyp "."))
         )
         (setq |e0 (redraw |e0 4))
      )
   )
   (*error* nil)
)

John F. Uhden

0 Likes