Close

Relief for ODA Team in Ukraine

Learn more
ODA BimRv SDK
Work with TfObject

OdTfObject is an extension of the OdRxObject class and provides methods to access information about an object's class.

To get the class describing an instance that is dynamically associated with the current object (class type is unknown), use the isA() method, which requires no parameters and returns the class description as a pointer to an OdTfClass object. For example:


OdDbHandle iHandle = pIO->getInt("Enter handle:", OdEd::kInpDefault, -1);
// Get the element
OdBmElementPtr pElementPtr = pDb->getObjectId(OdDbHandle(iHandle)).safeOpenObject();
// Get its TfClass
if (pElementPtr.isNull())
{
  message.format(L"Invalid handle");
  pIO->putString(message);
  return;
}
OdTfClass* pClass = pElementPtr->isA();
    

If the class type is known (class that describes the instance is statically associated with the current object), use the desc() method, which requires no parameters and returns the class description as a pointer to an OdTfClass object. For example:


pClass = pElementPtr ->desc();
    

To check whether the current object is an instance of the specified class or its derived classes, use the isKindOf() method, which requires a pointer to the OdTfClass instance and returns the checked result as a bool value. For example:


message.format(L"\nCurrent object is %s of the %s class", ((pElementPtr->isKindOf(pClass)) ? L"kind of" : L"not a kind of"), pClass->name().c_str());
pIO->putString(message);
    

To get a value of a particular parameter of the object, use the getProperty() method, which requires four parameters: input property name as an OdString value, output OdTfVariant object to return the parameter value, output ItemIndexType object to specify the index of the parameter in an array if it has an array type, and input pointer to an OdTfClass object to specify the parameter class (if set to NULL, the class of the current object will be taken). For example:


OdString name;
name.format(L"Height");
OdTfVariant val;
pElementPtr->getProperty(name, val);
    

See Also

Work with Tf Interface

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