Sunday, February 21, 2010

Assigning Extended Entity Data to an AutoCAD Object.

Once the application name for the extended entity has been registered in the applications identification table, extended data may now be assigned to an AutoCAD object. This is usually accomplished by appending the extended data to the object definition data using one of the many list functions provided in AutoLISP. Then the entity data is updated in the AutoCAD drawing database using ENTMOD function and assigned the extended information. Before extended data can be appended to an existing entity, it must be contained within an association list that starts with the code –3 and is followed by the name of the application with which the data is associated. Extended data can only be assigned to existing AutoCAD objects. The entity must either already exist or be created before the extended data can be assigned. An object can be assigned multiple application names and extended entity data. The following program illustrates how extended data can be assigned to an AutoCAD object.


 

(DEFUN c:extended_entity_data ()

(SETQ select_entity (ENTGET (CAR (ENTSEL))))

; Gets the association list of

; definition data for the entity

; selected.

(REGAPP "EXAMPLE_1_EXTENDED_DATA"); Registers the application name

; EXAMPLE_1_EXTENDED_DATA

(SETQ    extend_data            ; Sets the variable extend_data

; equal

         '((-3

             ("EXAMPLE_1_EXTENDED_DATA"

                        ; to the new extended data, which

; is a text string and two

; scaleable values 1041 and

; 1042.

             (1000 . "Imagine what can be saved to extended entity data")

             (1041 . 4.5)

             (1042 . 10.0)

             )

             )            ; End of association list

            )            ; End of QUOTE function

    new_entity_def

         (APPEND select_entity extend_data)

)

                        ; Appends the extended entity data

; to the object definition data.

(ENTMOD new_entity_def)        ; Updates the entity defination in

; the AutoCAD database with the new

; definition data containing the

; extended entity data.

)

No comments:

Post a Comment