Global attribute

Discussion in 'AutoCAD' started by masterbike360, Jan 11, 2005.

  1. I want to edit one attribute on several TAB. Normally I use GATTE (ExpreesTools) to do that manually.
    I would like to include this in a lisp. I cant make it work.
    I dont want to answer each promt manualy, I want everything included in the lisp file.
    I try (c:gatte) but I don't know how to answer the question via my lisp.

    Thanks, Simon
     
    masterbike360, Jan 11, 2005
    #1
  2. masterbike360

    T.Willey Guest

    How many time is this block inserted? Is it only inserted as the ones you want to change? If so then you can search the entire drawing, then get the attributes and search for the one whose tag matches the one you want to change, then you can put in your new information.

    Tim
     
    T.Willey, Jan 11, 2005
    #2
  3. Yes Tim, we inset it once (we load it from template at the TAB). It's a titleblock. I have to change the tag value (DOC_NAME) with (getvar "DWGNAME").
    I try to modify this partial line of command from an another post...but it's not good, no result

    (setq ss (ssget "x" '((0 . "INSERT") (66 . 1))))
    (while (setq Ent (ssname ss 0))
    (ssdel Ent ss)
    (setq Att Ent)
    (while (/= (cdr (assoc 0 (entget Att))) "CAD_JS2000_D")
    (setq Att (entnext Att))
    (if (= (cdr (assoc 2 (entget Att))) "DOC_NAME")
    (entmod (cons 1 (getvar "dwgname")) (assoc 1 Att) Att)
    )
    )
    )

    Simon
     
    masterbike360, Jan 11, 2005
    #3
  4. masterbike360

    T.Willey Guest

    That looks like one I wrote. Lol.

    (setq ss (ssget "x" '((0 . "INSERT") (66 . 1)(2 . "CAD_JS000_D"))))
    (while (setq Ent (ssname ss 0))
    (setq Att Ent)
    (while (setq Att (entnext Att))
    (if (= (cdr (assoc 2 (entget Att))) "DOC_NAME")
    (entmod (cons 1 (getvar "dwgname")) (assoc 1 Att) Att)
    )
    )
    (ssdel Ent ss)
    )

    I took it as if "CAD_JS2000_D" is your title block name, so I just added that to the ssget search to get even less items.

    See how this works for you.
    Tim
     
    T.Willey, Jan 11, 2005
    #4
  5. masterbike360

    Jeff Mishler Guest

    Here's one for editing 1 or more attributes globally. Use the second
    function to get all of the attributes from one block to copy to all other
    like named blocks. For changing only one attribute, use like this:
    (global_atts "blockname" '(("tagstring" . "newvalue")))

    Code:
    ;; Function to synchronize attributes of a given block, only those included
    in
    ;; the list will be updated
    ;; usage- (global_atts "myblock" *att_list*)
    ;; *att_list* as returned (or in the same form as) by the second routine,
    ;; "make_att_list"
    ;; Author: Jeff Mishler
    ;; Date 1/11/05
    (defun global_atts (bname attlist)
    (if (setq ss (ssget "x" (list '(0 . "INSERT")(cons 2 bname)'(66 . 1))))
    (progn
    (setq count -1)
    (while (< (setq count (1+ count)) (sslength ss))
    (setq blk (vlax-ename->vla-object (ssname ss count))
    atts2 (vlax-invoke blk "getattributes")
    )
    (foreach att2 atts2
    (foreach att1 attlist
    (if (= (car att1)(vla-get-tagstring att2))
    (progn
    (vla-put-textstring att2 (cdr att1))
    (vla-update att2)
    )
    )
    )
    (vla-update blk)
    )
    )
    )
    )
    
    ;; for use with the global_atts function above
    (defun make_att_list (/ ent obj atts)
    (and (setq ent (car (entsel "\nSelect block to log attributes for: ")))
    (setq obj (vlax-ename->vla-object ent))
    (if (and (vlax-property-available-p obj 'hasattributes)
    (eq (vla-get-hasattributes obj) :vlax-true))
    (progn
    (setq atts (vlax-invoke obj 'getattributes))
    (foreach att atts
    (setq *att_list* (cons
    (cons
    (vla-get-tagstring att)
    (vla-get-textstring att)
    )
    *att_list*
    )
    )
    )
    )
    )
    )
    )
    
     
    Jeff Mishler, Jan 11, 2005
    #5
  6. Thank you guy's...Now everything work fine.

    Simon
     
    masterbike360, Jan 12, 2005
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.