Author Topic: Cross layout attribute editting  (Read 8853 times)

0 Members and 1 Guest are viewing this topic.

CADaver

  • Guest
Cross layout attribute editting
« on: March 18, 2004, 09:44:48 AM »
Let's say I have DRAWN-BY as an attirbute in a block called TITLE.  How do I go about changing that attribute from whatever it is now (could be anything) to "CADaver" (or whatever I key in as a response to NEW VALUE?) in every layout?

hudster

  • Gator
  • Posts: 2848
Cross layout attribute editting
« Reply #1 on: March 18, 2004, 10:41:14 AM »
you could write a script to do it.

I done this with 250 drawings changed all from tender to Building warrant without having to do each one individually.

Code: [Select]
;;;EDIT TITLE BLOCK;;;
-ATTEDIT
NO
NO
TITLE                      ;;Block I want to change
DRAWING-STATUS    ;;;Attribute I want to change
TENDER                   ;;;Current attribute value
TENDER                   ;;;Value I wish to change
BUILDING WARRANT ;;;New attribute value


Saved me about 2 hours work
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

CADaver

  • Guest
Cross layout attribute editting
« Reply #2 on: March 18, 2004, 10:52:53 AM »
I was looking for something a little different, I'm quite aware of -attedit N N and use it frequently.  

I have a little function that promts the user for some info and changes the attributes accordingly.  Unfortunatly, it only changes the first layout tab.  I was looking for some direction in automating the manipulation of all matching attribute tags, regardless of "tab" location.

daron

  • Guest
Cross layout attribute editting
« Reply #3 on: March 18, 2004, 11:35:22 AM »
This is by no means a finished idea. Maybe as a group we can build it, if anybody's interested.
Code: [Select]

(defun attribute-list (x)
     (vlax-safearray->list
 (vlax-variant-value
      (vla-GetAttributes x)
 )
     )
)

(defun each-attribute (x string newval)
     (if (= (vlax-get-property x 'TagString) string)
 (vlax-put-property
      x
      'TextString
      (vlax-make-variant newval vlax-vbstring)
 )
     )
)

;;; FUNCTION
;;; Create a LIST of VLA-OBJECTS from a SELECTION SET
;;; Does not verify SELECTION SET or LIST
;;;
;;; ARGUMENTS
;;; ss = valid selection set
;;; lst = nil or valid list
;;;
;;; USAGE
;;; (setq ss (ssget))
;;; (setq vl-objs (ss->vla-list ss nil)
;;;
;;; add to the previous list of VLA-OBJECTS
;;; (setq ss (ssget))
;;; (setq vl-objs (ss->vla-list ss vl-objs))
;;;
;;; PLATFORMS
;;; 2000+
;;;
;;; AUTHOR
;;; Copyright© 2003 Mark S. Thomas
;;; mark.thomas@theswamp.org
;;;
;;; VERSION
;;; 1.0 Fri Nov 21, 2003
(defun ss->vla-list (ss lst)
  (cond ((ssname ss 0)
    (setq lst (append (list
      (vlax-ename->vla-object (ssname ss 0))) lst))
     (ss->vla-list (ssdel (ssname ss 0) ss) lst)); 1st cond
    ((null (ssname ss 0)) lst); 2nd cond
    ); cond
  )

(defun blocksel (bname)
     (ss->vla-list (ssget "x" (list (cons 2 bname))))
)


(foreach item (blocksel "addblocknamehere")
 (setq att-list (attribute-list item))
 (foreach att att-list
      (each-attribute att "tagnamehere" "newvaluehere")
 )
     )


attribute-list function added to work with the foreach portion above. Sorry about not adding it before. I actually had it in, but didn't see it in any other code, so I erased it. P.S. All the above code is in pieces and parts. You'll need to work out how to put it all together. There might be more to it that you need. Also, Mark's part of it is just the ss->vla-list function and YES, it is a sweet function.

CADaver

  • Guest
Cross layout attribute editting
« Reply #4 on: March 18, 2004, 01:26:27 PM »
I'm getting an error with ss->vla-list   ; error: too few arguments

I'm assuming that ss->vla-list is some bit of magic cooked up by some magician floating around here?  cuz' I can't find any help on it.

ronjonp

  • Needs a day job
  • Posts: 7527
Cross layout attribute editting
« Reply #5 on: March 18, 2004, 01:27:09 PM »
Cadaver,

You have express tools? If so, Global Attribute edit will do what you want. (gatte)

HTH

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ELOQUINTET

  • Guest
Cross layout attribute editting
« Reply #6 on: March 18, 2004, 01:32:32 PM »
yeah that's what i was thinking gatte does that. if you don't have express check out trevs global attribute editor in show your stuff. i think it's actually better than the express one.

CADaver

  • Guest
Cross layout attribute editting
« Reply #7 on: March 18, 2004, 01:33:58 PM »
Quote from: ronjonp
Cadaver,You have express tools? If so, Global Attribute edit will do what you want. (gatte)


Sorta, I was looking for something a little more automatic.  Key-in a command reply with user name and boom, the block is modified for current date, time, user name, etc. without having to edit each one.

CADaver

  • Guest
Cross layout attribute editting
« Reply #8 on: March 18, 2004, 01:38:50 PM »
Quote from: eloquintet
check out trevs global attribute editor in show your stuff. i think it's actually better than the express one.


I use that quite often, slick tool.  I was looking for something a little more idiot-proof for the 150 users around here.  What I've been using only works on the first block it finds, and ignores the blocks in subsequent layout tabs.

I'm really intriged by daron's post of Mark's routine.  Ifn' I kin figger it out.

daron

  • Guest
Cross layout attribute editting
« Reply #9 on: March 18, 2004, 01:49:09 PM »
My first post has been updated. Check notes at the bottom.

SMadsen

  • Guest
Cross layout attribute editting
« Reply #10 on: March 18, 2004, 01:53:11 PM »
A simple approach:

Code: [Select]
(defun changeAtt (ent tag val / entl ins)
  (setq ins ent)
  (while (and ent
           (/= "SEQEND" (cdr (assoc 0 (setq entl (entget ent))))))
    (if (and (= (cdr (assoc 0 entl)) "ATTRIB")
             (= (cdr (assoc 2 entl)) tag))
      (entmod (subst (cons 1 val) (assoc 1 entl) entl)))
    (setq ent (entnext ent)))
  (entupd ins)
)

(defun C:CADaver ()
  (cond ((setq sset (ssget "X" '((2 . "TITLE") (66 . 1))))
         (setq a 0)
         (repeat (sslength sset)
           (setq ent (ssname sset a)
                 a   (1+ a)
           )
           (changeAtt ent "DRAWN-BY" "CADaver") ;<- change value
         )
        )
  )
  (princ)
)

daron

  • Guest
Cross layout attribute editting
« Reply #11 on: March 18, 2004, 02:26:02 PM »
Fine. Just give it to him. I see how it is.






Nah, I would've if I had more time. All that stuff was previously written.

CADaver

  • Guest
Cross layout attribute editting
« Reply #12 on: March 18, 2004, 02:32:34 PM »
Thanks guys, I appreciate the steering.  I think I now have enough hammers to beat this into submission.  I'll let you know how it works out.

SMadsen

  • Guest
Cross layout attribute editting
« Reply #13 on: March 18, 2004, 02:33:28 PM »
Hey, you're not allowed to hog CADaver by having him spend time on thinking about how to write lisp. I need him to keep my favorite subject alive in Lagniappe :)

.. and that stuff was previously written anyway

CADaver

  • Guest
Cross layout attribute editting
« Reply #14 on: March 18, 2004, 02:37:17 PM »
Quote from: Daron
Fine. Just give it to him. I see how it is.
Come on, cut 'em some slack, everyone knows how lisp-challenged I am.

I'm still looking at that bit of code you've posted.  That has potential for even more mayhem than I was originally looking for...  :twisted: ... hee hee hee.  Thanks.

Man I gotta learn this stuff.