DXF Group Codes

Many ObjectARX functions return the type codes defined in the preceding table. However, in results from the functions that handle entities, the restype field contains DXF group codes, which are described in the AutoCAD Customization Guide. For example, in an entity list, a restype field of 10 indicates a point, while a restype of 41 indicates a real value.

AutoCAD drawings consist of structured containers for database objects having the following components:

Database objects are objects without layer, linetype, color, or any other geometric or graphical properties, and entities are derived from objects and have geometric and graphical properties.

Because DXF codes are always less than 2,000 and the result type codes are always greater, an application can easily determine when a result-buffer list contains result values (as returned by acedGetArgs(), for example) or contains entity definition data (as returned by acdbEntGet() and other entity functions).

The following figure shows the result-buffer format of a circle retrieved by acdbEntGet():

The following sample code fragment shows a function, dxftype(), that is passed a DXF group code and the associated entity, and returns the corresponding type code. The type code indicates what data type can represent the data: RTREAL indicates a double-precision floating-point value, RT3DPOINT indicates an ads_point, and so on. The kind of entity (for example, a normal entity such as a circle, a block definition, or a table entry such as a viewport) is indicated by the type definitions that accompany this function:

#define ET_NORM 1 // Normal entity  
#define ET_TBL  2 // Table  
#define ET_VPORT  3 // Table numbers  
#define ET_LTYPE  4 
#define ET_LAYER  5 
#define ET_STYLE  6 
#define ET_VIEW   7 
#define ET_UCS    8 
#define ET_BLOCK  9 
// Get basic C-language type from AutoCAD DXF group code (RTREAL,
// RTANG are doubles, RTPOINT double[2], RT3DPOINT double[3], 
// RTENAME long[2]). The etype argument is one of the ET_
// definitions. 
//
// Returns RTNONE if grpcode isn't one of the known group codes. 
// Also, sets "inxdata" argument to TRUE if DXF group is in XDATA.  
//
short dxftype(short grpcode, short etype, int *inxdata) 
{ 
    short rbtype = RTNONE; 
    *inxdata = FALSE; 
    if (grpcode >= 1000) {  // Extended data (XDATA) groups
        *inxdata = TRUE; 
        if (grpcode == 1071) 
            rbtype = RTLONG; // Special XDATA case  
        else 
            grpcode %= 1000; // All other XDATA groups match.  
    } // regular DXF code ranges  
    if (grpcode <= 49) { 
        if (grpcode >= 20) // 20 to 49  
            rbtype = RTREAL; 
        else if (grpcode >= 10) { // 10 to 19  
            if (etype == ET_VIEW) // Special table cases
                rbtype = RTPOINT; 
            else if (etype == ET_VPORT && grpcode <= 15) 
                rbtype = RTPOINT; 
            else // Normal point  
                rbtype = RT3DPOINT; // 10: start point, 11: endpoint
        } 
        else if (grpcode >= 0) // 0 to 9  
            rbtype = RTSTR; // Group 1004 in XDATA is binary
        else if (grpcode >= -2) 
            // -1 = start of normal entity -2 = sequence end, etc.  
            rbtype = RTENAME; 
        else if (grpcode == -3) 
            rbtype = RTSHORT; // Extended data (XDATA) sentinel 
    } 
    else { 
        if (grpcode <= 59) // 50 to 59  
            rbtype = RTANG; // double  
        else if (grpcode <= 79) // 60 to 79  
            rbtype = RTSHORT; 
        else if (grpcode < 210) 
            ;  
        else if (grpcode <= 239) // 210 to 239  
            rbtype = RT3DPOINT; 
        else if (grpcode == 999) // Comment  
            rbtype = RTSTR; 
    } 
    return rbtype; 
} 

An application obtains a result-buffer list (called rb), representing an entry in the viewport symbol table, and the following C statement calls dxftype():

ctype = dxftype(rb->restype, ET_VPORT, &inxdata); 

Suppose rb->restype equals 10. Then dxftype() returns RTPOINT, indicating that the entity is a two-dimensional point whose coordinates (of the type ads_real) are in rb->resval.rpoint[X] and rb->resval.rpoint[Y].