Author Topic: Global Attribute Update?  (Read 6171 times)

0 Members and 1 Guest are viewing this topic.

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
Global Attribute Update?
« on: February 23, 2005, 12:08:12 PM »
I use model space to create all of geometry then I use the Layout Tabs and create viewports in paperspace. In paperspace I insert my titleblock as a block w attributes.  If I have a 15 sheet drawing and the phone number changes or the project name changes I must go to every sheet and update the attributes.  I am triing to creat a routine that will automatically update all of the layout tabs for me.  I have created a routine to get the information from the corrected sheet but I can't for the life of me figure out how to get that info to update in the other tabs.  THe routine that generates the info send it out in an assoc list like such:

((PROJECTNAME . My Project)(PROJECTNUMBER . TGS001))

I have about eight of them total in the list)

Could someone lead me in the right direction as to how to go about this?

(Maybe I just need to eat?  Yeah me  thinks so.  I'll be right back.  BK here I come)
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright 2016

daron

  • Guest
Global Attribute Update?
« Reply #1 on: February 23, 2005, 12:30:02 PM »
Tim, I think if you define your parameters through activex, you should be able to vla-put-textstring to a vla-get-tagname or however you intend to autochange them, run them through a mapcar or foreach procedure and that should take care of it. Too bad you can't just put the block in Mspace and viewport to each in each layout?!?

DanB

  • Bull Frog
  • Posts: 344
Global Attribute Update?
« Reply #2 on: February 23, 2005, 12:32:58 PM »
Have you tried the Global Attribute Editor command "gatte?" Not sure if this is an express tool function or not...

Eloquintet

  • Gator
  • Posts: 3206
Global Attribute Update?
« Reply #3 on: February 23, 2005, 12:35:47 PM »
am i missing something, you can't do this with express tools gatte command?
Dan

AutoCAD Architecture 2015

Eloquintet

  • Gator
  • Posts: 3206
Global Attribute Update?
« Reply #4 on: February 23, 2005, 12:37:33 PM »
the only pitfall of this is that all of the layouts have to be in one drawing file but it does what you want i believe.
Dan

AutoCAD Architecture 2015

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
Global Attribute Update?
« Reply #5 on: February 23, 2005, 12:47:28 PM »
Yes Gatte works fine for one at a time, I have 8-10 that I would like to do at once.  I'll look into the activeX aproach and see if I can go from there.

Thanks Everyone
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright 2016

Eloquintet

  • Gator
  • Posts: 3206
Global Attribute Update?
« Reply #6 on: February 23, 2005, 12:53:16 PM »
i don't follow tim it does multiple. after you input the new text it asks if you want to change all layouts and bingo it changes them all. maybe i'm misinterpreting your intentions  :?
Dan

AutoCAD Architecture 2015

CADaver

  • Guest
Re: Global Attribute Update?
« Reply #7 on: February 23, 2005, 01:00:39 PM »
Try HERE  Look for ChangeAtt lisp code.

Eloquintet

  • Gator
  • Posts: 3206
Global Attribute Update?
« Reply #8 on: February 23, 2005, 01:15:49 PM »
ok cadaver i loaded that lisp and it does nothing for me. what is supposed to happen after user enters initials?
Dan

AutoCAD Architecture 2015

Eloquintet

  • Gator
  • Posts: 3206
Global Attribute Update?
« Reply #9 on: February 23, 2005, 01:21:05 PM »
cadaver i'm no expert but is that just for creating a plotstamp? if so, what's wrong with this method it works great for me? again maybe i'm way off dunno?

http://afralisp.com/lisp/rtext.htm
Dan

AutoCAD Architecture 2015

CADaver

  • Guest
Global Attribute Update?
« Reply #10 on: February 23, 2005, 03:22:11 PM »
Quote from: ELOQUINTET
ok cadaver i loaded that lisp and it does nothing for me. what is supposed to happen after user enters initials?
You got my Stamp lisp instead of ChangeAtt.

Here:


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)
)


Now you just need to pass it the desired data in the form of

Code: [Select]
(changeatt ent <attribute tag> <newvalue>)

CADaver

  • Guest
Global Attribute Update?
« Reply #11 on: February 23, 2005, 03:37:21 PM »
Quote from: ELOQUINTET
cadaver i'm no expert but is that just for creating a plotstamp? if so, what's wrong with this method it works great for me? again maybe i'm way off dunno?

http://afralisp.com/lisp/rtext.htm
A couple of reasons.  
One not everyone has express tools RTEXT and some of those people are our clients.  

Another is legacy, RTEXT is an express tool that may or may not be supported in the next release.  I am loathe to build a procedure on something that may vaporize at a whim.

RTEXT is "live", it updates the date and time continuously.  That's not what our stamp is for.  We want to know the last time the file was editted, not saved. (Also our stamp requires no outside text file)

Finally (and mostly) the stamp routine we're using has been in use considerably longer than rtext has been around.  That thread was just to make it update across all layouts at once.

Eloquintet

  • Gator
  • Posts: 3206
Global Attribute Update?
« Reply #12 on: February 23, 2005, 04:10:49 PM »
understood, all valid points. when i try to do as you said i get this though, you know why?

Command: (changeatt ent <dpk> <dpp>)
; error: bad argument type: lentityp nil
Dan

AutoCAD Architecture 2015

CADaver

  • Guest
Global Attribute Update?
« Reply #13 on: February 23, 2005, 10:36:06 PM »
Quote from: ELOQUINTET
understood, all valid points. when i try to do as you said i get this though, you know why?
Command: (changeatt ent <dpk> <dpp>)
; error: bad argument type: lentityp nil


Okay, first understand that CHANGEATT is a subroutine that needs to be run "inside" another routine.  In that routine you define "ENT".  Look at the sample code below; CADAVER is the main routinie that collects data then calls the subroutine changeatt.  ENT is defined by:

Code: [Select]
((setq sset (ssget "X" '((2 . "TITLE") (66 . 1))))
         (setq a 0)
         (repeat (sslength sset)
           (setq ent (ssname sset a)
                 a   (1+ a)
           )


It finds the blocks called "TITLE", then steps through them one at a time (using A and A+1).  One at a time, it sets ENT with:
 setq ent (ssname sset a)

Look back below. Once ENT is defined it is passed to CHANGEATT along with a known attribute tag name "DRAWN_BY" and a new value for that tag "CADAVER" like this;
(changeAtt ent "DRAWN-BY" "CADaver")

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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)
)


~~~~~~~~~~~~~~~~~~~~~~~~~~

Now you need to modify the routine c:CADAVER above to find your block name, instead of "TITLE", and use your attribute tag name, instead of "DRAWN-BY", and fill in your new value instead of "CADaver".

Now, everyone here knows I'm a lisp hack at my very best, so my description may leave a lot to be desired.  Maybe one of the real gurus around here (Yo, Mark, Stig, CAB, Daron, anybody) could flesh it out a little better.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Global Attribute Update?
« Reply #14 on: February 23, 2005, 11:41:16 PM »
If you prefer the activeX stuff, Something like this may suit you ..

If you feed it attribute tags that dont exist, it just chages the ones it can ..
Code: [Select]

(defun C:DrawnByMe (/ Index SSET)
  (cond ((setq sset (ssget '((2 . "TITLE") (66 . 1))))
         (setq Index -1)
         (repeat (sslength sset)
           (SetAttVals
             (vlax-ename->vla-object (ssname sset (setq Index (1+ Index))))
             (list (cons "DRAWN-BY" "ME")
                   (cons "DATE" "TODAY"))
           )
         )
        )
  )
  (princ)
)

(defun SetAttVals (oBlockref dotPairList / AttVal)
  (mapcar
    '(lambda (Attrib)
       (if (setq
             AttVal (cdr (assoc (vla-get-tagstring Attrib) dotPairList))
           )
         (vla-put-textstring Attrib AttVal)
       )
     )    
    (vlax-invoke oBlockref 'GetAttributes) ; saves a translation
   
  )
  (vla-update oBlockref)
  (princ)
)


Edit: What spell checker ?
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--