<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Set Colour 'By Block' LISP? in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/set-colour-by-block-lisp/m-p/9486022#M75220</link>
    <description>&lt;P&gt;Here's an old one...&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;(defun C:BB ( / *error* @Anonymous |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
   ; Revised (11-17-16) for freeware

   (gc)
   (prompt "\nBB v15.00 (c)1994-2000, John F. Uhden, Cadlantic")
   (prompt "\nThis routine will redefine all entities in a block to color BYBLOCK.")
    (or *acad* (setq *acad* (vlax-get-acad-object)))
    (or *doc* (setq *doc* (vla-get-ActiveDocument *acad*)))
    (vla-endundomark *doc*)
    (vla-startundomark *doc*)

   (defun *error* (|err)
      (@reset)
      (if (wcmatch (strcase |err) "*CANCEL*,*QUIT*")
         (vl-exit-with-error "\r                                              ")
         (vl-exit-with-error (strcat "\r*ERROR*: " |err))
      )
   )
   (defun @Anonymous ()
      (vla-endundomark *doc*)
      (if (= (type |e0) 'ENAME) (redraw |e0 4))
      (vl-doc-set '$cv_cmdname "")
      (princ)
   )

   (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/&amp;lt;No&amp;gt;: "))
               (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))
      )
   )
   (@reset)
)
&lt;/LI-CODE&gt;
&lt;P&gt;Make nothing of the pipe symbol prefix "|."&amp;nbsp; It's just a style I used before local variables were really local.&lt;/P&gt;</description>
    <pubDate>Fri, 01 May 2020 21:10:10 GMT</pubDate>
    <dc:creator>john.uhden</dc:creator>
    <dc:date>2020-05-01T21:10:10Z</dc:date>
    <item>
      <title>Set Colour 'By Block' LISP?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/set-colour-by-block-lisp/m-p/9485002#M75217</link>
      <description>&lt;P&gt;Hi, I find I often have to open up blocks and change the colour from 'by layer' to 'by block'. Does anyone have a lisp to make this faster and easier? It would be great if I could do multiple blocks at once. There is a useful command setbylayer I just wish there was the same thing for set by block.&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2020 12:54:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/set-colour-by-block-lisp/m-p/9485002#M75217</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-05-01T12:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: Set Colour 'By Block' LISP?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/set-colour-by-block-lisp/m-p/9485406#M75218</link>
      <description>&lt;P&gt;@Anonymous&amp;nbsp; hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;check this one, let you specify block name and set all it's entities color to byblock.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;enjoy&lt;/P&gt;&lt;P&gt;Moshe&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(vl-load-com)

(defun c:colorByBlock (/ blkName color)
 (cond
  ((eq (setq blkName (getstring "\nBlock name: ")) "") 
   nil
  )
  ((null (tblsearch "block" blkName))
   (vlr-beep-reaction)
   (prompt (strcat "\nblock " blkName " is not found."))
  )
  ( t
   (setq color (vlax-create-object (strcat "AutoCAD.AcCmColor." (substr (getvar "acadver") 1 2))))
   (vla-put-colorIndex color AcByBlock)
   
   (vlax-for AcDbEntity (vla-item
                          (vla-get-blocks
                               	(vla-get-activedocument
                                   	(vlax-get-acad-object)
                                )
                          )
                          blkName
                        )   
    (vla-put-trueColor AcDbEntity color)  
    (vlax-release-object AcDbEntity)
   ); vlax-for
   
   (princ "\nDone.") 
  )
 ); cond

 (princ) 
); c:colorByBlock&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2020 15:57:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/set-colour-by-block-lisp/m-p/9485406#M75218</guid>
      <dc:creator>Moshe-A</dc:creator>
      <dc:date>2020-05-01T15:57:14Z</dc:date>
    </item>
    <item>
      <title>Re: Set Colour 'By Block' LISP?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/set-colour-by-block-lisp/m-p/9485959#M75219</link>
      <description>See this other post in the forum &lt;A href="https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/set-color-to-quot-byblock-quot-for-entities-inside-blocks/td-p/7962346" target="_blank"&gt;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/set-color-to-quot-byblock-quot-for-entities-inside-blocks/td-p/7962346&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;HTH</description>
      <pubDate>Fri, 01 May 2020 20:19:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/set-colour-by-block-lisp/m-p/9485959#M75219</guid>
      <dc:creator>pendean</dc:creator>
      <dc:date>2020-05-01T20:19:24Z</dc:date>
    </item>
    <item>
      <title>Re: Set Colour 'By Block' LISP?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/set-colour-by-block-lisp/m-p/9486022#M75220</link>
      <description>&lt;P&gt;Here's an old one...&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;(defun C:BB ( / *error* @Anonymous |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
   ; Revised (11-17-16) for freeware

   (gc)
   (prompt "\nBB v15.00 (c)1994-2000, John F. Uhden, Cadlantic")
   (prompt "\nThis routine will redefine all entities in a block to color BYBLOCK.")
    (or *acad* (setq *acad* (vlax-get-acad-object)))
    (or *doc* (setq *doc* (vla-get-ActiveDocument *acad*)))
    (vla-endundomark *doc*)
    (vla-startundomark *doc*)

   (defun *error* (|err)
      (@reset)
      (if (wcmatch (strcase |err) "*CANCEL*,*QUIT*")
         (vl-exit-with-error "\r                                              ")
         (vl-exit-with-error (strcat "\r*ERROR*: " |err))
      )
   )
   (defun @Anonymous ()
      (vla-endundomark *doc*)
      (if (= (type |e0) 'ENAME) (redraw |e0 4))
      (vl-doc-set '$cv_cmdname "")
      (princ)
   )

   (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/&amp;lt;No&amp;gt;: "))
               (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))
      )
   )
   (@reset)
)
&lt;/LI-CODE&gt;
&lt;P&gt;Make nothing of the pipe symbol prefix "|."&amp;nbsp; It's just a style I used before local variables were really local.&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2020 21:10:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/set-colour-by-block-lisp/m-p/9486022#M75220</guid>
      <dc:creator>john.uhden</dc:creator>
      <dc:date>2020-05-01T21:10:10Z</dc:date>
    </item>
  </channel>
</rss>

