Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Custom field displaying value from xdata

9 REPLIES 9
Reply
Message 1 of 10
rhesusminus
1723 Views, 9 Replies

Custom field displaying value from xdata

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


Trond Hasse Lie
AutoCAD Electrical and EPLAN expert
Ctrl Alt El
Please select "Accept Solution" if this post answers your question. 'Likes' won't hurt either. 😉
9 REPLIES 9
Message 2 of 10
_Tharwat
in reply to: rhesusminus

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 ?

Message 3 of 10
rhesusminus
in reply to: _Tharwat

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


Trond Hasse Lie
AutoCAD Electrical and EPLAN expert
Ctrl Alt El
Please select "Accept Solution" if this post answers your question. 'Likes' won't hurt either. 😉
Message 4 of 10
_Tharwat
in reply to: rhesusminus

 

Question : what is the value of the xdata that you have in an object ?

Message 5 of 10
rhesusminus
in reply to: _Tharwat

The value will be a string, like "START".

 

THL


Trond Hasse Lie
AutoCAD Electrical and EPLAN expert
Ctrl Alt El
Please select "Accept Solution" if this post answers your question. 'Likes' won't hurt either. 😉
Message 6 of 10
_Tharwat
in reply to: rhesusminus

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

Message 7 of 10
rhesusminus
in reply to: _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


Trond Hasse Lie
AutoCAD Electrical and EPLAN expert
Ctrl Alt El
Please select "Accept Solution" if this post answers your question. 'Likes' won't hurt either. 😉
Message 8 of 10
_Tharwat
in reply to: rhesusminus

Actually I do not think it is possible since the Xdata is not connected to an entity through the ObjectID .

 

Regards,

 

Tharwat

Message 9 of 10
dgorsman
in reply to: rhesusminus

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.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Message 10 of 10
rhesusminus
in reply to: dgorsman

Well, thanks for all answers. I was hoping to get maximum flexibility while using standard AutoCAD functionality.

Will look for other solution instead 🙂

 

THL


Trond Hasse Lie
AutoCAD Electrical and EPLAN expert
Ctrl Alt El
Please select "Accept Solution" if this post answers your question. 'Likes' won't hurt either. 😉

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost