PDA

View Full Version : Update/Reset Attributes to default values?


Mr Cory
2007-03-12, 01:06 AM
Does anyone a have a lisp routine to update/reset att text to the default? By up date i mean if the attribute default is changed then existing one update to the new default

anderson.scottglen
2007-03-12, 06:41 PM
Quick and dirty, but works on my end:(defun c:default( / entdps)
(setq entdps nil)
(while (and (/= (cdr (assoc 0 entdps)) "ATTRIB") (/= (cdr (assoc 0 entdps)) "ATTDEF"))
(if (/= (cdr (assoc 0 entdps)) nil)
(setq entdps (entget (car (nentsel "\n -Selection was not an attribute, select again please: "))))
(setq entdps (entget (car (nentsel "\n Select attribute to reset to the default value: "))))))
(cond
((= (cdr (assoc 0 entdps)) "ATTRIB")
(setq entdps (subst (cons 1 (cdr (assoc 2 entdps))) (assoc 1 entdps) entdps)))
((= (cdr (assoc 0 entdps)) "ATTDEF")
(setq entdps (subst (cons 2 (cdr (assoc 1 entdps))) (assoc 2 entdps) entdps)))
(t nil))
(entmod entdps)
(command "regen")
(princ)
)

T.Willey
2007-03-12, 08:55 PM
Quick and dirty, but works on my end:(defun c:default( / entdps)
(setq entdps nil)
(while (and (/= (cdr (assoc 0 entdps)) "ATTRIB") (/= (cdr (assoc 0 entdps)) "ATTDEF"))
(if (/= (cdr (assoc 0 entdps)) nil)
(setq entdps (entget (car (nentsel "\n -Selection was not an attribute, select again please: "))))
(setq entdps (entget (car (nentsel "\n Select attribute to reset to the default value: "))))))
(cond
((= (cdr (assoc 0 entdps)) "ATTRIB")
(setq entdps (subst (cons 1 (cdr (assoc 2 entdps))) (assoc 1 entdps) entdps)))
((= (cdr (assoc 0 entdps)) "ATTDEF")
(setq entdps (subst (cons 2 (cdr (assoc 1 entdps))) (assoc 2 entdps) entdps)))
(t nil))
(entmod entdps)
(command "regen")
(princ)
)
This won't set it to the default value, it will set it to the Tag value.

If you want the default, use this one.

((lambda (/ Sel EntData Tag BlkEnt flag tempEntData)

(if
(and
(setq Sel (nentsel "\n Select attribute to set to default: "))
(setq EntData (entget (car Sel)))
(= (cdr (assoc 0 EntData)) "ATTRIB")
(setq Tag (cdr (assoc 2 EntData)))
(setq BlkEnt (tblobjname "block" (cdr (assoc 2 (entget (cdr (assoc 330 EntData)))))))
)
(while
(and
(setq BlkEnt (entnext BlkEnt))
(not flag)
)
(setq tempEntData (entget BlkEnt))
(if
(and
(= (cdr (assoc 0 tempEntData)) "ATTDEF")
(= Tag (cdr (assoc 2 tempEntData)))
)
(progn
(entmod (subst (cons 1 (cdr (assoc 1 tempEntData))) (assoc 1 EntData) EntData))
(entupd (cdr (assoc -1 EntData)))
(setq flag T)
)
)
)
)
(princ)
))

anderson.scottglen
2007-03-12, 09:44 PM
Ah, right you are. Good catch, thanks. Want this one for myself as well =)

T.Willey
2007-03-12, 09:58 PM
Ah, right you are. Good catch, thanks. Want this one for myself as well =)
You're welcome.

Mr Cory
2007-03-12, 10:34 PM
Very cool! Thanks, it mostly worked lol, i have feilds referencing to lookup tables in a dynmanic block which lose them link to the lookup.

T.Willey
2007-03-12, 11:04 PM
Very cool! Thanks, it mostly worked lol, i have feilds referencing to lookup tables in a dynmanic block which lose them link to the lookup.
I don't use fields or dynamic blocks yet, so I'm not sure what to do, but maybe someone who does can modify the code to work the way you want.

Mr Cory
2007-03-12, 11:48 PM
Owell all good! Thanks for all your help!