ODA IFC SDK Developer's Guide > IFC Data Management > Standard Data Access Interface in IFC SDK > Work with Attributes > Work with Attributes of Simple Data Types
Work with Attributes of Simple Data Types

The following are simple data types of attributes:

  • sdaiINTEGER
  • sdaiREAL
  • sdaiNUMBER
  • sdaiBOOLEAN
  • sdaiLOGICAL
  • sdaiSTRING
  • sdaiINSTANCE

Any application instance can contain attributes of any data type listed above. To get access to an attribute, use the sdaiGetAttrBN() function in the following routine:

  1. Get an application instance via a _sdaiGetEntityById() function call:
    
    SdaiAppInstance applicationInstance = _sdaiGetEntityById(model, 5);
    if ((applicationInstance == NULL) || (sdaiErrorQuery() != sdaiNO_ERR))
      return;
            
  2. Call the sdaiGetAttrBN() function:
    
    SdaiAppInstance developer = NULL;
    if (sdaiGetAttrBN(applicationInstance, "applicationdeveloper", sdaiINSTANCE, &developer ) == NULL)
      return;
      
    if ((developer == NULL) || (sdaiErrorQuery() != sdaiNO_ERR))
      return;
            

    The sdaiGetAttrBN() function accepts four parameters:

    • An instance.
    • A name of the attribute.
    • A data type of the requested attribute.
    • A placeholder for the attribute value. The function fills it with the attribute value if successful or NULL otherwise.

    The code fragment illustrates how to get an attribute represented with an instance.

Below you can find another example of getting access to a simple attribute value: a string value of the version. In the first case, it is retrieved as a string and the sdaiGetAttrBN() function returns it successfully; in the second case, you can see an attempt to get a string attribute as an integer value. This attempt fails; the sdaiGetAttrBN() function returns NULL, and the sdaiErrorQuery() function returns an sdaiVT_NVLD value.


SdaiString version = NULL;
if ((sdaiGetAttrBN(applicationInstance, "version", sdaiSTRING, &version ) == NULL) || (odStrCmpA(version, "2019") != 0) || (sdaiErrorQuery() != sdaiNO_ERR))
  return;

SdaiInteger wrongAttrType = -1;
if (sdaiGetAttrBN(applicationInstance, "version", sdaiINTEGER, &wrongAttrType ) == NULL)
  return;
    

Another kind of simple type is an enumeration. SDAI also supports getting enumeration values from an application instance.

For example, an .ifc file contains an entry in the DATA section:


// #43= IFCSIUNIT(*,.LENGTHUNIT.,.MILLI.,.METRE.);
    

The string value within the dots is an enumeration value. Below you can see a code fragment that read this value.


// #43= IFCSIUNIT(*,.LENGTHUNIT.,.MILLI.,.METRE.);
SdaiAppInstance applicationInstance = _sdaiGetEntityById(model, 43);
if ((applicationInstance == NULL) || (sdaiErrorQuery() != sdaiNO_ERR))
  return;

SdaiEnum  enumValue = NULL;
// if successful, the enumValue contains "MILLI"
if (sdaiGetAttrBN(applicationInstance, "prefix", sdaiENUM, &enumValue ) == NULL)
  return;
    

See Also

Work with Select Attributes

Work with Attributes

Copyright © 2002 – 2021. Open Design Alliance. All rights reserved.