Attachment of Extended Data to an Entity

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.