Run Time Class Identification



    R3CLID clid;

    R3GetAttrs(obj,
               R3RA_ClassId, &clid,
               R3TAG_END);
    if(clid == R3CLID_SPHERE)
         ...

It is also possible to ask if an object is of certain class by calling R3ObjectIsOfKind();


    R3BOOL isofkind;

    isofkind = (R3BOOL)R3ObjectIsOfKind(obj, R3CLID_SPHERE);

This returns true if the object's class or one of the super classes of it matche the given class id. For example,


    R3ObjectIsOfKind(obj, R3CLID_ROOT);

returns always TRUE because all objects are derived from the root class.

Warning: You should actually try to avoid using run time class identification because it often indicates that you are writing 'procedural ' code rather than 'object oriented'. In object oriented programming, program flow should automatically flow into correct classes. If it doesn't you are on the wrong track.