Thus to add a string one must put a 1001 group code into the integer array and the string value into the variant array at the same position. Without this value, the extended data does not have a valid registered application name and will not be added. The function shown in Listing 2 can be used to obtain a unique name for your extended data, or you can simply make one up as shown in Listing 3. All you need to do is use it, and it will be added to the registered names for you automatically. But if you want to guarantee that the name you are using is your own, registering it first is the only way to go.
Variants allow for multiple data storage types all referenced with a common name.
The member of a list or variant array can be of any supported data type. When the SetXData member is used with a valid entity object, the extended data is written to the object in the drawing database. Internally the system converts the data in the variant array using the group codes supplied in the integer array to store the data in proper containers. Although the data type is found in the variant data elements themselves, your application may want to treat the values differently and thus the group codes are required to further classify the data. For example, group code 1040 signifies a normal real number, but you use group code 1041 when you want the number to be automatically updated whenever the object is scaled.