PDA

View Full Version : linking attributes



whdjr
2004-08-05, 06:42 PM
Is there a way to add code or some other kind of text to an attribute so that it will read the value of another attribute within the same block?

RobertB
2004-08-05, 07:29 PM
AutoCAD 2005 Fields ought to be able to do that.

whdjr
2004-08-05, 07:42 PM
what about pre 2005 (ie. 2000)?

RobertB
2004-08-05, 08:09 PM
Automatic, so that when the user edits one attribute, the other updates? Or just run-at-your-choosing? Reactors could do it automatically, but it is more work (samples may be available in the Exchange). Run-at-your-choosing is simple. See my article in the July/Aug 2004 AUGIWorld for code access to attributes.

peter
2004-08-07, 11:32 AM
Here is a little lisp code to get you started.

Peter Jamtgaard



(defun C:VLRATTS (/ lstObjects lstSelection)
(while (setq lstSelection (entsel "\nSelect Blocks with Attributes: "))
(setq lstObjects (cons (vlax-ename->vla-object (car lstSelection)) lstObjects))
)
(setq rxnAttribute (vlr-object-reactor lstObjects "DATA" '((:vlr-subObjModified . ATTS2)))
rxnComEnd (vlr-editor-reactor nil '((:vlr-commandended . ATTS1)))
)
)
(defun ATTS1 (CALL CALLBACK)
(print CALL)
(print CALLBACK)
(if lstChangedPairs
(progn
(setq blnReRun T)
(print lstChangedPairs)
; Manipulate attributes here!
(setq lstChangedPairs nil)
)
)
)
(defun ATTS2 (objOwner objReactor lstEntity)
(print objOwner)
(print objReactor)
(if (not blnRerun)
(setq lstChangedPairs (cons (cons objOwner
(vlax-ename->vla-object (car lstENtity))
)
lstChangedPairs
)
)
)
)