Sunday, February 21, 2010

Retrieving Extended Entity Data from an AutoCAD Object

When an object has been assigned extended entity data it cannot be accessed using traditional AutoCAD object listing or entity modifying commands (LIST, DDMODIFY, PROPERTIES, etc.). This alone ensures the developer that the information assigned to the object can not be tampered with by the user. The only way the information can be extracted once it has been assigned is with the use of the ENTGET function. Recall from Chapter Four that when this function is supplied with any entity's name it returns the definition data for the specified object. However, after a closer examination of the function's syntax one important aspect emerges. This function, when supplied with an application name in addition to the entity name, returns the entity definition along with the extended entity data that is associated with the specified application. For example, to obtain the extended entity data that was assigned to an object by the previous program, the following syntax would be used.

Command: (SETQ entity_data (ENTGET (CAR (ENTSEL)) '("EXAMPLE_1_EXTENDED_DATA"))) ~EnterKey~

Select object:

((-1 . <Entity name: 2770500>) (0 . "LINE") (5 . "20") (100 .

"AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbLine") (10 2.19416 5.16515 0.0) (11 5.15258 2.37318 0.0) (210 0.0 0.0 1.0) (-3 ("EXAMPLE_1_EXTENDED_DATA" (1000 . "Imagine what can be saved to extended entity data") (1041 . 4.5) (1042 . 10.0))))

Command:

In order to retrieve the xdata assigned to each application associated with an object, all applications names must be supplied to the ENTGET function. To retrieve the extended entity data appended to an object's definition data by the application names applications EXAMPLE_1_EXTENDED_DATA and EXAMPLE_2_EXTENDED_DATA, the following syntax would be used.

No comments:

Post a Comment