TheSwamp

CAD Forums => CAD General => Topic started by: PHX cadie on August 14, 2007, 11:01:05 PM

Title: Color of Attributes in blocks
Post by: PHX cadie 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)
Title: Re: Color of Attributes in blocks
Post by: Dinosaur on August 14, 2007, 11:06:51 PM
and you could be trying this in Microstation
Title: Re: Color of Attributes in blocks
Post by: M-dub 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?
Title: Re: Color of Attributes in blocks
Post by: M-dub 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...
Title: Re: Color of Attributes in blocks
Post by: PHX cadie 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

Title: Re: Color of Attributes in blocks
Post by: PHX cadie 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:)
Title: Re: Color of Attributes in blocks
Post by: Kerry 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 ..

Title: Re: Color of Attributes in blocks
Post by: CADaver 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")
Title: Re: Color of Attributes in blocks
Post by: PHX cadie 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 ! !
Title: Re: Color of Attributes in blocks
Post by: T.Willey 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
    )
   )
  )
 )
)
)
Title: Re: Color of Attributes in blocks
Post by: T.Willey 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)
 )
)
Title: Re: Color of Attributes in blocks
Post by: hudster 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)
)
Title: Re: Color of Attributes in blocks
Post by: CADaver 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.
Title: Re: Color of Attributes in blocks
Post by: CottageCGirl 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)...???
Title: Re: Color of Attributes in blocks
Post by: Keith™ 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
Title: Re: Color of Attributes in blocks
Post by: PHX cadie on August 15, 2007, 11:09:30 AM
Whoa   :-o

All you guys are just too darn good!

I am in awe, THANKS!
Title: Re: Color of Attributes in blocks
Post by: deegeecees on August 15, 2007, 11:20:04 AM
If you want to run one of the examples in a batch, this works fairly well. Just need to add the commands where it it says "COMMANDS FOR BATCH GO HERE".

Code: [Select]
(DEFUN C:batch_anything ()

;;;;;;;;;;;;;;;;;;;;;;;;;Select directory to be processed

(setq dfil (getfiled "Select A File In The Directory You Want To Batch Process" "p:/" "dwg" 0))
(setq wutdir (vl-filename-directory dfil))
(setq wutfiles (vl-directory-files wutdir "*.dwg"))

(setq scrfile (open "c:\\scrfile.scr" "w"))
(close scrfile)
(setq scrfile (open "c:\\scrfile.scr" "a"))

(foreach n wutfiles
(setq n2 (strcat "\""wutdir "\\" n "\""))
(setq n2 (vl-string-translate "\\" "\\" n2))
(setq scrline (strcat "open" " " n2 " " "(load\"batch_core\")" " " "batch_insert" " " "qsave" " " "close"));;;;;;;COMMANDS FOR BATCH GO HERE
(write-line scrline scrfile)
(princ)
)

(close scrfile)
(command "script" "c:\\scrfile")

(princ "\n***Batch complete.***")
(princ)


);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;DEFUN
Title: Re: Color of Attributes in blocks
Post by: ronjonp on August 15, 2007, 11:31:14 AM
This will put all attributes to color bylayer (if the layer is not locked) and update the block definition.

Spawned from:
http://www.theswamp.org/index.php?topic=16987.msg206466#msg206466

Code: [Select]
(defun c:rjp-att2bylayer (/ blkobj lays ss)
  (setq lays (vla-get-layers
       (vla-get-activedocument (vlax-get-acad-object))
     )
ss   (ssget "x" '((0 . "INSERT") (66 . 1)))
  )
  (if ss
    (progn
      (setq ss
     (mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex ss)))
      )
      (mapcar
'(lambda (b)
   (if (eq (vla-get-lock (vla-add lays (vla-get-layer b)))
   :vlax-false
       )
     (progn
       (mapcar
'(lambda (a)
    (vla-put-color a 256)
  )
(vlax-invoke b 'getattributes)
       )
       (vlax-for blkobj (vla-item
  (vla-get-blocks
    (vla-get-activedocument
      (vlax-get-acad-object)
    )
  )
  (vla-get-name b)
)
(mapcar
   '(lambda (c)
      (vla-put-color blkobj 256)
    )
   (vlax-invoke b 'getattributes)
)
       )
     )
     (princ (strcat "\n Block "
    (vla-get-name b)
    " on locked layer "
    (vla-get-layer b)
    " not updated..."
    )
     )
   )
)
ss
      )
    )
  )
  (princ)
)

Ron
Title: Re: Color of Attributes in blocks
Post by: CADaver on August 15, 2007, 11:52:01 AM
If you want to run one of the examples in a batch, this works fairly well. Just need to add the commands where it it says "COMMANDS FOR BATCH GO HERE".
ahh cool, that's a keeper

A long time ago I built a "dummy" profile with a "dummy" menu that had nothing in it and a "dummy" MNL.  When I need to batch something, I'll modify the "dummy" MNL for the functions (including "save" and "close"), then just open a directory worth of files.
Title: Re: Color of Attributes in blocks
Post by: deegeecees on August 15, 2007, 12:09:16 PM
ahh cool, that's a keeper

Thanks. With all the support I've gotten over the years, I figured I could give something back once in a while (although my expertise is basically hack mode).
Title: Re: Color of Attributes in blocks
Post by: PHX cadie on August 15, 2007, 12:42:25 PM
OK, I'm back in this because you guys are having way too fun  :-D

Problem 1 I did not mention:
Bylayer will not work because all the text attributes are forced yellow

Problem 2:
the sections have various names, ie bubble-left-up, bubble-up-left, etc, prob ~6 names for the sections bubbles depending on orientation.
So, will a script file with multiple file names work?

-insert oldblock=newblock
-insert oldblock1=newblock1
-insert oldblock2=newblock2 y [esc]
attsync oldblock


Don't think(?) using layers will work, (because they are blocks). Need to experiment w/ that one.

Right now I'm refedit, attsync, which knocks out 4-6 at a time, (tremendous help). You guys could prob use batchs/scripts and get this done in an hour.Its my lack of knowledge
 :oops:
Title: Re: Color of Attributes in blocks
Post by: CADaver on August 15, 2007, 12:51:41 PM
Mulitple redefines should work a breeze in a script or a function
ATTSYNC will work with wildcards so ATTSYNC N * will sync 'em all.

When you redefine the block, move the attributes to a layer and make it whatever color you want.  ATTSYNC should overide the forced color.
Title: Re: Color of Attributes in blocks
Post by: Keith™ on August 15, 2007, 12:57:14 PM
ATTSYNC should overide the forced color.

It will ....
Title: Re: Color of Attributes in blocks
Post by: ronjonp on August 15, 2007, 01:12:17 PM
Quote
Problem 1 I did not mention:
Bylayer will not work because all the text attributes are forced yellow

Then your attributes were put on a wrong layer? If you run my routine, the attributes color should match the color of the layer they reside on...
Title: Re: Color of Attributes in blocks
Post by: PHX cadie on August 15, 2007, 01:45:35 PM
Hate agrue w/ Mr. Computer, but....

This is my script:
Code: [Select]
-insert SECT-MARKER=SECT-MARKER1 y [esc]
attsync SECT-MARKER


This is Mr. Computers reply:

Code: [Select]
-Command: _SCRIPT
Enter script file name <H:\Client\Phoenix_PHXC\7360A10\DWGS\XREF
Files\91-S-017-EPSSECS.scr>: "C:\Greg\MISC\LISP\UP05.SCR"

Command: -insert Enter block name or [?] <SECTION-MARKER1>:
SECT-MARKER=SECT-MARKER1
"SECT-MARKER1.dwg": Can't find file in search path:
  C:\Documents and Settings\GDavis\My Documents\ (current directory)
  H:\Client\Phoenix_PHXC\7360A10\DWGS\XREF Files\
  L:\AutoCAD 2005\R16.1\enu\Support\
  L:\
  L:\BLOCKS\Symbol Manager\
  C:\Documents and Settings\carollo\Application Data\Autodesk\AutoCAD
2005\R16.1\enu\support\
  C:\Program Files\AutoCAD 2005\support\
  C:\Program Files\AutoCAD 2005\fonts\
  L:\FONTS\
  C:\Program Files\AutoCAD 2005\help\
  C:\Program Files\AutoCAD 2005\express\
  C:\Program Files\AutoCAD 2005\support\color\
  L:\LISP\
  L:\VBA\
  C:\Greg\MISC\
  C:\Greg\MISC\Bitmaps\
  C:\Greg\MISC\LISP\
  C:\Greg\
  L:\AutoCAD 2005\R16.1\enu\Support\Color\
  C:\Program Files\AutoCAD 2005\
*Invalid*

  C:\Greg\                                                                            .......yes it is
  H:\Client\Phoenix_PHXC\7360A10\DWGS\XREF Files\       .......yes it is


 :|  (but is my first attempt)

Title: Re: Color of Attributes in blocks
Post by: PHX cadie on August 15, 2007, 02:13:11 PM
 :oops:

<Note to self use correct file name>

 :oops:

Sorry,
Now to really screw things up  :evil:
Title: Re: Color of Attributes in blocks
Post by: PHX cadie on August 15, 2007, 05:32:19 PM
No mass damage yet
It seems as though:

Code: [Select]
-insert SECT-MARKER=SECT-MARKER1 y [esc]
-insert det-MARKER=det-MARKER1 y [esc]
-insert BUB-DN-RIGHT=BUB-DN-RIGHT1 y [esc]
ATTSYNC N *

only inserts the first line (SECT-MARKER). It asks for a y scale and insertion point and inserts only the revised SECT-MARKER.
What am I missing?
Title: Re: Color of Attributes in blocks
Post by: Kerry on August 15, 2007, 05:59:40 PM
you do know that both blocks can have the same name, don't you ?

(command "-insert" "SECT-MARKER=c:/SECT-MARKER" )(command)


so you don't need the "Y"


Title: Re: Color of Attributes in blocks
Post by: mjfarrell on August 15, 2007, 06:49:42 PM
Kerry, if the user wasn't around say prior to R10 they are not aware of the Block=Block command
Title: Re: Color of Attributes in blocks
Post by: PHX cadie on August 15, 2007, 07:33:58 PM
you do know that both blocks can have the same name, don't you ?

(command "-insert" "SECT-MARKER=c:/SECT-MARKER" )(command)

so you don't need the "Y"

Yes, in the code I put a number 1 behind each revised block name. Is that what youre refering to?

I dont understand about the "Y". <edit....now I see it>
Title: Re: Color of Attributes in blocks
Post by: mjfarrell on August 15, 2007, 07:39:10 PM
what he is saying is you wouldn't need to add a 1 to the revised block name, as you are performing a 1:1 replacement...only me thinks you got that already
Title: Re: Color of Attributes in blocks
Post by: PHX cadie on August 15, 2007, 08:02:22 PM
 :oops:
My mistake. I should keep the Y (as to replace) and have the same block name.

If I remove all the "1" behind the names, will all blocks in the code be inserted? It seems only the first one is, sect-marker.
Title: Re: Color of Attributes in blocks
Post by: mjfarrell on August 15, 2007, 08:24:39 PM
post a copy of your code so we can see what you are doing
Title: Re: Color of Attributes in blocks
Post by: PHX cadie on August 15, 2007, 08:34:00 PM
Code: [Select]
-insert SECT-MARKER=SECT-MARKER y [esc]
-insert det-MARKER=det-MARKER y [esc]
-insert BUB-DN-RIGHT=BUB-DN-RIGHT y [esc]
ATTSYNC N *

It should insert 3 blocks right?

Let me know if I start to get annoying 
Till this AM I didn't know how to post codes  :-)
Title: Re: Color of Attributes in blocks
Post by: Kerry on August 15, 2007, 08:44:11 PM
phx,
forget the script for a moment .. what do you think this does ?
Code: [Select]
(DEFUN c:test ()
    (COMMAND "-insert" "CROSS2=c:/Alphabet Soup")(COMMAND)
    (COMMAND "-insert" "MARKER=c:/Alphabet Soup")(COMMAND)   
    (COMMAND "ATTSYNC" "N" "*")
)
Title: Re: Color of Attributes in blocks
Post by: Kerry on August 15, 2007, 08:46:45 PM
Then this ..

Code: [Select]
(DEFUN c:test ()
    (COMMAND "-insert" "SECT-MARKER=c:/SECT-MARKER")
    (COMMAND)
    (COMMAND "-insert" "det-MARKER=c:/det-MARKER")
    (COMMAND)
    (COMMAND "-insert" "BUB-DN-RIGHT=c:/BUB-DN-RIGHT")
    (COMMAND)
    (COMMAND "ATTSYNC" "N" "*")
)
Title: Re: Color of Attributes in blocks
Post by: PHX cadie on August 15, 2007, 08:57:06 PM
phx,
forget the script for a moment .. what do you think this does ?
Code: [Select]
(DEFUN c:test ()
    (COMMAND "-insert" "CROSS2=c:/Alphabet Soup")(COMMAND)
    (COMMAND "-insert" "MARKER=c:/Alphabet Soup")(COMMAND)   
    (COMMAND "ATTSYNC" "N" "*")
)

Thinkin:

lsp inserting 2 blocks, one that will be named "cross2" the other "marker" both coming from Alphabet Soup.dwg. 2 block, 2 names, same dwg
attsync: updates the attributes, by any name (*)

The 2nd should replace 3 existing block of the same name and update atts

maybe?
Title: Re: Color of Attributes in blocks
Post by: Kerry on August 15, 2007, 09:02:10 PM
close,

In this case it replaces the DEFINITION of the blocks cross2 and marker with the contents of Alphabet Soup.dwg

Any inserts in the drawing are updated with the new definition

the Attsync updates the attributes.


Clear ?
Title: Re: Color of Attributes in blocks
Post by: Kerry on August 15, 2007, 09:07:29 PM
try this

Save this as Test-ReplaceBlock.lsp to c:\
Code: [Select]
(DEFUN c:Test-ReplaceBlock ()
    (COMMAND "-insert" "SECT-MARKER=c:/SECT-MARKER")
    (COMMAND)
    (COMMAND "-insert" "det-MARKER=c:/det-MARKER")
    (COMMAND)
    (COMMAND "-insert" "BUB-DN-RIGHT=c:/BUB-DN-RIGHT")
    (COMMAND)
    (COMMAND "ATTSYNC" "N" "*")
)

Save this as Batch_Stuff.lsp to c:\
Code: [Select]
(DEFUN C:batch_Stuff ()
;;;;;;;;;;;;;;;;;;;;;;;;;Select directory to be processed
    (SETQ dfil (GETFILED "Select A File In The Directory You Want To Batch Process"
                         "p:/"
                         "dwg"
                         0
               )
    )
    (SETQ wutdir (VL-FILENAME-DIRECTORY dfil))
    (SETQ wutfiles (VL-DIRECTORY-FILES wutdir "*.dwg"))
    (SETQ scrfile (OPEN "c:\\scrfile.scr" "w"))
    (CLOSE scrfile)
    (SETQ scrfile (OPEN "c:\\scrfile.scr" "a"))
    (FOREACH n wutfiles
        (SETQ n2 (STRCAT "\"" wutdir "\\" n "\""))
        (SETQ n2 (VL-STRING-TRANSLATE "\\" "\\" n2))
        ;;(setq scrline (strcat "open" " " n2 " " "(load\"batch_core\")" " " "batch_insert" " " "qsave" " " "close"));;;;;;;COMMANDS FOR BATCH GO HERE
        (SETQ scrline (STRCAT "open"            " "
                              n2                " "
                              "(load\"c:Test-ReplaceBlock\")"
                              " "               "Test-ReplaceBlock"
                              " "               "qsave"
                              " "               "close"
                             )
        )
        (WRITE-LINE scrline scrfile)
        (PRINC)
    )
    (CLOSE scrfile)
    (COMMAND "script" "c:\\scrfile")
    (PRINC "\n***Batch complete.***")
    (PRINC)
)

put your revised blocks in c:\
in a new drawing, load and run Batch_Stuff.lsp
Select the folder with the drawing to change ( it will change ALL drawings)
Title: Re: Color of Attributes in blocks
Post by: PHX cadie on August 15, 2007, 09:10:06 PM
Yes, first example defines the blocks

How'd I do on second?

Sorry I have go (6PM). Hopefully no traffic, kiss the wife, kick the kids, back in 45 min. PLs don't think I'm leaving, this is important to me & Thanks
Title: Re: Color of Attributes in blocks
Post by: PHX cadie on August 15, 2007, 11:28:08 PM
 :-o

I have one dwg to experiment with and test-replaceblock worked like a charm.

I can't wait to try the batch file. Just wanted you to know it took me 1 day to go through ~ 1/2 the stack I have to revise. Tomorrow the other 1/2 will take what?....30 seconds. I am in your debt.

Just curious, how long did it take to write batch_stuff?

I really need to learn this stuff.
Title: Re: Color of Attributes in blocks
Post by: Kerry on August 15, 2007, 11:34:44 PM
I've run complicated batches at excess of 1000 / hour.

Work till morning tea time then take 4 days off ... well not quite, but you know what I mean ...

The batch_stuff file is essentially as posted in a previous post by deegeecee http://www.theswamp.org/index.php?topic=18200.msg221683#msg221683  with your stuff added ( one line only )

Title: Re: Color of Attributes in blocks
Post by: Kerry on August 15, 2007, 11:50:31 PM
Yes, first example defines the blocks

How'd I do on second?

Sorry I have go (6PM). Hopefully no traffic, kiss the wife, kick the kids, back in 45 min. PLs don't think I'm leaving, this is important to me & Thanks


Yes, and yes and pat the dog for me will you ?

I was in a long Messenger convo' (we use headsets for meetings) with a remote co-worker, so I'm pleased you were'nt waiting for me :-)
Title: Re: Color of Attributes in blocks
Post by: PHX cadie on August 16, 2007, 12:49:04 PM
9:48AM in Arizona........do believe its time for tea !   :wink:
Title: Re: Color of Attributes in blocks
Post by: deegeecees on August 16, 2007, 01:15:18 PM
Just curious, how long did it take to write batch_stuff?

I created that in 2002 out of necessity, took about an hour of trial/error. I have other forms of batch processes in VBA for plotting/zipping, and tons of ObjectDBX stuff. But sadly, I hardly get to play with them anymore.
Title: Re: Color of Attributes in blocks
Post by: PHX cadie on August 16, 2007, 03:05:00 PM
and I "Thank You" also.

Pls take note, (I start @7 finished ~10), in 3hrs I did what took a full day yesterday. It took 3 hours because of making individual files of corrected blocks, finding exploded blocks  :pissed: and wrong layers, etc. So 3 hrs verses 9 hrs......not too shabby!

Oh... wish you all could have seen the Boss's face when I brought it back.

I love guys  :-D
Title: Re: Color of Attributes in blocks
Post by: Keith™ on August 16, 2007, 03:38:50 PM
I love guys  :-D

and I love gals ;)
Title: Re: Color of Attributes in blocks
Post by: deegeecees on August 16, 2007, 04:07:13 PM
Oh... wish you all could have seen the Boss's face when I brought it back.

My past and present bosses got used to that sort of thing (a little too used to it).

BTW you may want to edit your last post, so as not to confuse anyone.
Title: Re: Color of Attributes in blocks
Post by: deegeecees on August 17, 2007, 12:02:01 AM


and I love gals ;)

Ditto.

Just to clarify.

<Seinfeld> Not that there's anything wrong with that."</Seinfeld>
Title: Re: Color of Attributes in blocks
Post by: Kerry on August 17, 2007, 02:04:07 AM
PHX, Ignore these guys .. I knew what you meant.
Title: Re: Color of Attributes in blocks
Post by: craigr on August 20, 2007, 11:26:27 AM
My past and present bosses got used to that sort of thing (a little too used to it).

That's the problem with showing them something that you came up with or found on a disscussion board - When you run into a problem that you can't come up with a quicker fix, they get frustrated that you can't.

Sometimes it's better to keep your mouth shut and pat yourself on the back rather than asking them do it.

craigr