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:
((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") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(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.