Help: Entities with custom information

Discussion in 'AutoCAD' started by Toni Benedico, Nov 24, 2003.

  1. Hello,
    I would be grateful if sbdy help me with that:
    I'm trying to put custom information for my application inside some
    drawing entities. For example: in an "ARC" entity, I'd like to put a new
    custom code: (666 . "CounterClockwise") or (666 . "Clockwise"). I mean that,
    whether the 666 code already exists or not, my question is: "Can I add
    custom attributes? and how?, and how to access them later?"

    Thanks in advance,
    .- Toni

    PD: I'm writing it in LISP, in case it is relevant.
     
    Toni Benedico, Nov 24, 2003
    #1
  2. A snip from the online help:

    You can use xdata to store any type of information you want. For
    example, draw an entity (such as a line or a circle), then enter the
    following code to attach xdata to the entity:

    (setq lastent (entget (entlast))) ; Gets the association
    ; list of definition data
    ; for the last entity.
    (regapp "NEWDATA") ; Registers the
    ; application name.
    (setq exdata ; Sets the variable
    '((-3 ("NEWDATA" ; exdata equal to the
    (1000 . "This is a new thing!") ; new extended data—
    ))) ; in this case, a text
    ) ; string.
    (setq newent
    (append lastent exdata)) ; Appends new data list to
    ; entity's list.
    (entmod newent) ; Modifies the entity with the new
    ; definition data.
    To verify that your new xdata has been attached to the entity, enter the
    following code and select the object:

    (entget (car (entsel)) '("NEWDATA"))
    This example shows the basic method for attaching extended data to an
    entity.


    For more informations read the LISP online help, "Extended Data". You
    can also see a good example how to use XDATA in the Express Tool
    xdata.lsp.


    Juergen

    BTW: For Extended Entity Data you should use the codes 1000 and higher
    (not a code 666 in your example).
     
    Jürgen Palme, Nov 24, 2003
    #2
  3. Toni Benedico

    Jakub Guest

    BTW: For Extended Entity Data you should use the codes 1000 and higher
    Besides, Code 666 will invoke the Dark Lord himself, and you don't want him
    running around all over your screen.... ;-))
     
    Jakub, Nov 25, 2003
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.