Author Topic: Color of Attributes in blocks  (Read 8866 times)

0 Members and 1 Guest are viewing this topic.

PHX cadie

  • Water Moccasin
  • Posts: 1902
Color of Attributes in blocks
« on: August 14, 2007, 11:01:05 PM »
Man did I get handed a big one.

It seems some folks have taken a city standard block, ( a section bubble) and somehow forced all the colors of the linework and individual text attributes (yes 3 of them, Section Number, Pg from and pg on). Now I get to fix it, about 2 inches of paper.

I have thought of exploding the block and redefining, (takes care of the linework), but then the 3 attributes are still the wrong color.

Is there a quick fix w/o loosing the text and keeping the blocks intact.

If I remember right battman may be the answer, but I can't experiment at home.

Well on the bright side, at least I'll be employed till Socail Security kicks in
(Maybe the wife will Email pics of the kids Graduation)
Acad 2013 and XM
Back when High Tech meant you had an adjustable triangle

Dinosaur

  • Guest
Re: Color of Attributes in blocks
« Reply #1 on: August 14, 2007, 11:06:51 PM »
and you could be trying this in Microstation

M-dub

  • Guest
Re: Color of Attributes in blocks
« Reply #2 on: August 14, 2007, 11:08:06 PM »
So, wait a minute... Someone screwed up the block itself (the .dwg file) or after they were inserted into the drawings?

M-dub

  • Guest
Re: Color of Attributes in blocks
« Reply #3 on: August 14, 2007, 11:19:04 PM »
I believe the redefining of the blocks could be done via script after they're fixed.  This would reduce the amount of your time spent significantly, as a 2 inch stack of paper must equal what, about...300 drawings? Just a guess...

PHX cadie

  • Water Moccasin
  • Posts: 1902
Re: Color of Attributes in blocks
« Reply #4 on: August 14, 2007, 11:20:05 PM »
Nope, back to good ole ACAD for the time being.

No its not the block itself, it is the block in the dwg.

If I insert the block it has the wrong colors. If I x'plode/purge then insert they are fine.

Sorry for the lack of clarity

Acad 2013 and XM
Back when High Tech meant you had an adjustable triangle

PHX cadie

  • Water Moccasin
  • Posts: 1902
Re: Color of Attributes in blocks
« Reply #5 on: August 14, 2007, 11:25:26 PM »
I believe the redefining of the blocks could be done via script after they're fixed. 

I'm not that smart   :-D

a 2 inch stack of paper must equal what, about...300 drawings?

Will ok 1.5", the C sheets are good. (Imagine that   :angel:)
Acad 2013 and XM
Back when High Tech meant you had an adjustable triangle

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Color of Attributes in blocks
« Reply #6 on: August 14, 2007, 11:26:31 PM »
Have a look at the INSERT command
block name=file name

and imagine it used in a script ..

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

CADaver

  • Guest
Re: Color of Attributes in blocks
« Reply #7 on: August 14, 2007, 11:26:54 PM »
Wblock the block to "c:\directory\newblockname" then fix it

Code: [Select]
(command "-insert" "oldblockname=c:\directory\newblockname" (command))
(command "attsync" "n" "oldblockname")

PHX cadie

  • Water Moccasin
  • Posts: 1902
Re: Color of Attributes in blocks
« Reply #8 on: August 14, 2007, 11:43:37 PM »
Wblock the block to "c:\directory\newblockname" then fix it

Code: [Select]
(command "-insert" "oldblockname=c:\directory\newblockname" (command))
(command "attsync" "n" "oldblockname")

Ohh you've got me thinking, (not an easy task)!

Need to experiment and look @ insert.

Thanks All ! !
Acad 2013 and XM
Back when High Tech meant you had an adjustable triangle

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Color of Attributes in blocks
« Reply #9 on: August 15, 2007, 12:14:11 AM »
See if this works for you.
Code: [Select]
(defun c:abl(/ LayList ss Ent tmpEnt Lay Opt DiaRtn)
; Changes attributes layer, and color to bylayer.

(command "._undo" "_end")
(command "._undo" "_group")
(setq LayList
 (vl-sort
  (vl-remove-if
   '(lambda (x)
    (vl-string-search "|" x)
   )
   (TableList "layer")
  )
  '(lambda (a b)
   (< (strcase a) (strcase b))
  )
 )
)
(prompt "\nSelect blocks with attributes to match layers: ")
(if (setq ss (ssget '((0 . "INSERT") (66 . 1))))
 (while (setq Ent (ssname ss 0))
  (setq tmpEnt Ent)
  (if (not Lay)
   (progn
    (initget "Select")
    (if (= (setq Opt (getkword "\n <U>se layer of block, or Select layer from dialog? ")) "Select")
     (if (setq DiaRtn (SingleSelect LayList "Select layer to put attributes on." nil))
      (setq Lay (nth (car DiaRtn) LayList))
     )
    )
   )
  )
  (setq Lay (cdr (assoc 8 (entget Ent))))
  (while (/= (cdr (assoc 0 (setq EntData (entget (setq tmpEnt (entnext tmpEnt)))))) "SEQEND")
   (if (assoc 62 EntData)
    (setq EntData (subst (cons 62 256) (assoc 62 EntData) EntData))
   )
   (entupd (cdr (assoc -1 (entmod (subst (cons 8 Lay) (assoc 8 EntData) EntData)))))
  )
  (ssdel Ent ss)
 )
)
(command "._undo" "_end")
(princ)
)
(defun SingleSelect (Listof Message Toggle / DiaLoad tmpStr tmpTog tmpList)

(setq DiaLoad (load_dialog "MyDialogs.dcl"))
(if (new_dialog "SingleSelect" DiaLOad)
 (progn
  (start_list "listbox" 3)
  (mapcar 'add_list Listof)
  (end_list)
  (if Message
   (set_tile "text1" Message)
  )
  (if (not Toggle)
   (mode_tile "toggle1" 1)
  )
  (action_tile "listbox"
   "(if (= $reason 4)
    (progn
     (setq tmpStr (get_tile \"listbox\"))
     (if Toggle
      (setq tmpTog (get_tile \"toggle1\"))
     )
     (done_dialog 1)
    )
   )"
  )     
  (action_tile "accept"
   "(progn
    (setq tmpStr (get_tile \"listbox\"))
    (if Toggle
     (setq tmpTog (get_tile \"toggle1\"))
    )
    (done_dialog 1)
   )"
  )
  (action_tile "cancel" "(done_dialog 0)")
  (if (= (start_dialog) 1)
   (progn
    (setq tmpList (read (strcat "(" tmpStr ")")))
    (if (= tmpTog "1")
     (cons T tmpList)
     tmpList
    )
   )
  )
 )
)
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Color of Attributes in blocks
« Reply #10 on: August 15, 2007, 12:19:55 AM »
You can use this one to change the blocks definition.  Same dialog box file as above.
Code: [Select]
(defun c:CB (/ ActDoc BlkCol tmpList NameList tmpName RtnList tmpEnt bname tbl1 ob1 cnt Prefix Opt)
; Change block defination to layer 0 linetype to byblock
; Ignores Text, Mtext and Dimension Objects.

(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(vla-EndUndoMark ActDoc)
(vla-StartUndoMark ActDoc)
(setq BlkCol (vla-get-Blocks ActDoc))
(setvar "errno" 0)
(while (/= (getvar "errno") 52)
 (if
  (and
   (or
    Opt
    (initget "Yes No")
    (setq Opt (getkword "\n Put text and dimensions on layer 0 also? [Yes/No]<N>: "))
    (setq Opt "No")
   )
   (not (initget "Select All Prefix"))
   (setq tmpEnt (entsel "\nSelect block or [Select from a dialog box/select by Prefix]: "))
  )
  (cond
   ((= tmpEnt "All")
    (vlax-for Blk BlkCol
     (setq tmpName (vla-get-Name Blk))
     (if
      (and
       (= (vla-get-IsXref Blk) :vlax-false)
       (= (vla-get-IsLayout Blk) :vlax-false)
       (not (vl-string-search "|" tmpName))
      )
      (vlax-for i Blk
       (if
        (not
         (or
          (= (strcase (vla-get-Layer i)) "DEFPOINTS")
          (if (= Opt "No")
           (vl-position (vla-get-ObjectName i) '("AcDbText" "AcDbMtext" "AcDbDimension"))
          )
         )
        )
        (progn
         (vla-put-Layer i "0")
         (vla-put-LineType i "ByBlock")
         (vla-put-Color i "0")
        )
       )
      )
     )
    )
   )
   ((= tmpEnt "Select")
    (setq tmpList nil)
    (vlax-for Blk BlkCol
     (setq tmpName (vla-get-Name Blk))
     (if
      (and
       (= (vla-get-IsXref Blk) :vlax-false)
       (= (vla-get-IsLayout Blk) :vlax-false)
       (not (vl-string-search "|" tmpName))
       (/= (substr tmpName 1 1) "*")
      )
      (setq tmpList (cons Blk tmpList))
     )
    )
    (setq tmpList (vl-sort tmpList
     '(lambda (a b) (< (vla-get-Name a) (vla-get-Name b))))
    )
    (setq NameList (mapcar 'vla-get-Name tmpList))
    (if (setq RtnList (MultiSelect NameList "Select blocks to change settings" nil))
     (progn
      (foreach Num RtnList
       (setq Blk (nth Num tmpList))
       (vlax-for i Blk
        (if
         (not
          (or
           (= (strcase (vla-get-Layer i)) "DEFPOINTS")
           (if (= Opt "No")
            (vl-position (vla-get-ObjectName i) '("AcDbText" "AcDbMtext" "AcDbDimension"))
           )
          )
         )
         (progn
          (vla-put-Layer i "0")
          (vla-put-LineType i "ByBlock")
          (vla-put-Color i "0")
         )
        )
       )
      )
     )
    )
    (vla-Regen ActDoc acActiveViewport)
   )
   ((= tmpEnt "Prefix")
    (setq cnt 0)
    (if (/= (setq Prefix (getstring "\n Enter prefix to search block collection for: ")) "")
     (vlax-for Blk BlkCol
      (setq tmpName (vla-get-Name Blk))
      (if
       (and
        (= (strcase (substr (vla-get-Name Blk) 1 (strlen Prefix))) (strcase Prefix))
        (= (vla-get-IsXref Blk) :vlax-false)
        (= (vla-get-IsLayout Blk) :vlax-false)
        (not (vl-string-search "|" tmpName))
        (/= (substr tmpName 1 1) "*")
        (setq cnt (1+ cnt))
       )
       (vlax-for i Blk
        (if
         (not
          (or
           (= (strcase (vla-get-Layer i)) "DEFPOINTS")
           (if (= Opt "No")
            (vl-position (vla-get-ObjectName i) '("AcDbText" "AcDbMtext" "AcDbDimension"))
           )
          )
         )
         (progn
          (vla-put-Layer i "0")
          (vla-put-LineType i "ByBlock")
          (vla-put-Color i "0")
         )
        )
       )
      )
     )
    )
    (prompt (strcat "\n Number of blocks found: " (itoa cnt)))
    (vla-Regen ActDoc acActiveViewport)
   )
   ((= (value 0 (entget (car tmpEnt))) "INSERT")
    (setq bname (value 2 (entget (car tmpEnt))))
    (setq tbl1 (tblobjname "block" bname))
    (while (setq tbl1 (entnext tbl1))
     (setq ob1 (vlax-ename->vla-object tbl1))
     (PutX ob1 'Layer "0")
     (PutX ob1 'LineType "ByBlock")
     (vla-put-color ob1 "0")
    )
    (vla-Regen ActDoc acActiveViewport)
   )
  )
 )
)
(vla-EndUndoMark ActDoc)
(princ)
)
(defun MultiSelect (Listof Message Toggle / DiaLoad tmpStr tmpTog tmpList)

(setq DiaLoad (load_dialog "MyDialogs.dcl"))
(if (new_dialog "MultiSelect" DiaLOad)
 (progn
  (start_list "listbox" 3)
  (mapcar 'add_list Listof)
  (end_list)
  (if Message
   (set_tile "text1" Message)
  )
  (if (not Toggle)
   (mode_tile "toggle1" 1)
  )
  (mode_tile "listbox" 2)
  (action_tile "accept"
   "(progn
    (setq tmpStr (get_tile \"listbox\"))
    (if Toggle
     (setq tmpTog (get_tile \"toggle1\"))
    )
    (done_dialog 1)
   )"
  )
  (action_tile "cancel" "(done_dialog 0)")
  (if (= (start_dialog) 1)
   (progn
    (if tmpStr
     (setq tmpList (read (strcat "(" tmpStr ")")))
    )
    (if (= tmpTog "1")
     (cons T tmpList)
     tmpList
    )
   )
  )
 )
)
)
(defun MakeX (entname)
  (vlax-ename->vla-object entname)
)

(defun GetX (object prop)
 (if (vlax-property-available-p object prop)
  (vlax-get object prop)
 )
)

(defun PutX (object prop val)
 (if (vlax-property-available-p object prop T)
  (vlax-put object prop val)
 )
)
« Last Edit: August 15, 2007, 12:21:39 AM by T.Willey »
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

hudster

  • Gator
  • Posts: 2848
Re: Color of Attributes in blocks
« Reply #11 on: August 15, 2007, 03:18:07 AM »
or this one to change colour, layer, rotation, height, style and case. (separate commands for each though)

Code: [Select]
; Change Attribute Properties en masse
;; A series of routines for changing attribute properties on a mass of attributes.
;; Can change each proprty, i.e. the layer, color, style, layer etc of many attributes at once.
;;
;; Also a routine to change attribute text to upper case.
;;
;; Another to transfer data from one attribute to another. Handy if you are updating or
;; replacing blocks with a new version, i.e. line number racetrack blocks. Also copies from
;; text to attribute but not from attribute to text.
;;
;; Another routine if you drawing piping GA's using line numbers for layer names. Get the
;; layer name from an object and paste into the attribute in a line number racetrack block.
;;


;;;Attribute style change
(defun c:asc ()
(setq atts(getstring "\nEnter new attribute style: "))
(command "attedit" "y" "*" "*" "*" "c" pause pause)
(while
(= 1 (logand (getvar "cmdactive") 1))
(command "s" atts "n")
);;; end while
);;; end lisp

;;;Attribute height change
(defun c:ahc ()
(setq atth(getreal "\nEnter new attribute height: "))
(command "attedit" "y" "*" "*" "*" "c" pause pause)
(while
(= 1 (logand (getvar "cmdactive") 1))
(command "h" atth "n")
);;; end while
);;; end lisp

;;;Attribute angle change
(defun c:aac ()
(setq atta(getint "\nEnter new attribute angle: "))
(command "attedit" "y" "*" "*" "*" "c" pause pause)
(while
(= 1 (logand (getvar "cmdactive") 1))
(command "a" atta "n")
);;; end while
);;; end lisp

;;;Attribute color change
(defun c:acc ()
(setq attc(getint "\nEnter new attribute color: "))
(command "attedit" "y" "*" "*" "*" "c" pause pause)
(while
(= 1 (logand (getvar "cmdactive") 1))
(command "c" attc "n")
);;; end while
);;; end lisp

;;;Attribute layer change
(defun c:alc ()
(setq attl(getstring "\nEnter new attribute layer: "))
(command "attedit" "y" "*" "*" "*" "c" pause pause)
(while
(= 1 (logand (getvar "cmdactive") 1))
(command "l" attl "n")
);;; end while
);;; end lisp

;;; Block attribute case change
(defun c:AttUpper ()
 (setq ATWC1(nentsel "\nSelect block data from: "))
  (setq ATWC2(car ATWC1))
   (setq ATWC3(entget ATWC2))
    (setq ATWC4(cdr(assoc 1 ATWC3)))
     (setq ATWC5(cdr(assoc 10 ATWC3)))
  (setq ATWCTXT (Strcase ATWC4))
(command "attedit" "n" "y" "*" "*" "*" ATWC5 "" ATWC4 ATWCTXT)
)

;;; Block attribute data transfer
(defun c:BADT ()
 (setq e1s(nentsel "\nSelect block data from: "))
 (setq e2s(nentsel "\nSelect block data to: "))
  (setq e1n(car e1s))
  (setq e2n(car e2s))
   (setq e1d(entget e1n))
   (setq e2d(entget e2n))
    (setq e1dd(cdr(assoc 1 e1d)))
    (setq e2dd(cdr(assoc 1 e2d)))
     (setq e1p(cdr(assoc 10 e1d)))
     (setq e2p(cdr(assoc 10 e2d)))
  (setq tt1 e1dd)
  (setq tt2 e2dd)
(command "attedit" "n" "y" "*" "*" "*" e2p "" tt2 tt1)
)

;;; Layer name to block attribute
(defun c:LTATT ()
 (setq en1s(nentsel "\nSelect entity on layer: "))
 (setq en2s(nentsel "\nSelect block data to: "))
  (setq en1n(car en1s))
  (setq en2n(car en2s))
   (setq en1d(entget en1n))
   (setq en2d(entget en2n))
    (setq en1dd(cdr(assoc 8 en1d)))
    (setq en2dd(cdr(assoc 1 en2d)))
     (setq en1p(cdr(assoc 10 en1d)))
     (setq en2p(cdr(assoc 10 en2d)))
  (setq ttn1 en1dd)
  (setq ttn2 en2dd)
(command "attedit" "n" "y" "*" "*" "*" en2p "" ttn2 ttn1)
)
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

CADaver

  • Guest
Re: Color of Attributes in blocks
« Reply #12 on: August 15, 2007, 08:18:23 AM »
Wblock the block to "c:\directory\newblockname" then fix it

Code: [Select]
(command "-insert" "oldblockname=c:\directory\newblockname" (command))
(command "attsync" "n" "oldblockname")

Ohh you've got me thinking, (not an easy task)!

Need to experiment and look @ insert.

Thanks All ! !
You can REFEDIT the block in one of the drawings (then ATTSYNC to clean up that drawing) THEN WBLOCK it for a clean start file.

CottageCGirl

  • Guest
Re: Color of Attributes in blocks
« Reply #13 on: August 15, 2007, 10:15:52 AM »
If there arent too many layers..couldn't you create new layer names with the correct colors..use layer translate...then purge the old layers....recreate the old layer names (if they are correct) and translate them back to the new corrected layers ( if layer names are important...if not ignore this step)...???

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Color of Attributes in blocks
« Reply #14 on: August 15, 2007, 10:24:40 AM »
Wblock the block, edit it to what you want it to look like, then this would do it in any single drawing, you likely could automate by use of a script

-insert oldblock=newblock y [esc]
attsync oldblock
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie