Hi.
Is it possible to make a text field "formula" that displays a value from some xdata in an object?
If so.. what should the formula look like?
THL
Hi
You can do instead of that by getting the data from an object to a filed string test by field command directely .if they
are things like ( distance , length , measurement , point , .... etc .
In my Opinion , to get the Xdata value that attached to an object is something won't be implemented because of the string itself of the Xdata Value .
Question : what is the value of the xdata that you want to include it within a filed text ?
I want multiple objects to have the same XDATA. Some objects (mybe a block) shall dilspay this information in an attributereference, other objects may just display the info in an MTEXT. Som objects won't be deisplaying the information at all.
I just want the flexibility while programming, to write the information to the same place (the xdata), no matter where/wether the information is displayed in the object.
THL
Question : what is the value of the xdata that you have in an object ?
The value will be a string, like "START".
THL
This is my first try with Xdata and here is what I have just wrote for you and hope this would meet your needs .
(defun c:CopyXdata (/ e vl sset) ;; Tharwat 20. 06. 2011 ;; Copy Xdata from entity to selection set of objects (vl-load-com) (if (and (setq e (car (entsel "\n Select Object that has Xdata : "))) (not (vla-getXData (setq vl (vlax-ename->vla-object e)) "" 'Xtype 'Xvalue ) ) (eval Xtype) (eval Xvalue) ) (progn (if (ssget "_:L") (progn (vlax-for vl (setq sset (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object) ) ) ) (vla-SetXdata vl Xtype Xvalue) ) (vla-delete sset) ) (princ) ) ) (princ) ) (princ) )
Tharwat
Thanks for helping Tharwat.
However, the problem isn't reading/writing the xdata to the objects.
The problem is to create a custom field in a attributereference, thats displays this xdata, and also updates if the xdata updates.
THL
Actually I do not think it is possible since the Xdata is not connected to an entity through the ObjectID .
Regards,
Tharwat
While it is possible to get XData attached to an object through its ObjectID, I don't think there is anything in the fields implementation which allows you to dig down that far. You might be able to get away with creating global LISP variables on the fly, then assigning that variable name to the field, but even at the top-level that sounds ugly and a lot of work (including global variable clean-up). For that amount of work you might be better off building a generic string builder to react to a regen event which pushes the values where they need to be.
Well, thanks for all answers. I was hoping to get maximum flexibility while using standard AutoCAD functionality.
Will look for other solution instead 🙂
THL