Close

Relief for ODA Team in Ukraine

Learn more
ODA BimRv SDK
Work with TfProperty

OdTfProperty stores property data.

To get the type of the property, use the type() method, which requires no parameters and returns the property type as one value from the OdTfVariant::Type enumeration:


typedef enum 
{
  kGUID = OdVariant::kNextType,
  kEmpty,
  kDEPRECARED0,
  kDbStubPtr,
  kRxObjectWeakPtr,
  kTuple,
  kNextType
} Type;
    

For example:


OdTfVariant::Type propType = pProp->type();
    

To get the name of the property, use the name() method, which requires no parameters and returns the name of the property as an OdString value. For example:


message.format(L"\nName of the parameter is %s", pProp->name().c_str());
pIO->putString(message);
    

To get the owner class of the property, use the owner() method, which requires no parameters and returns the owner class as a pointer to the OdTfClass object. For example:


message.format(L"\nCurrent property is owned by %s class", pProp->owner()->name().c_str());
pIO->putString(message);
    

Parameter can have a default value instead of OdTfVariant::kEmpty. To get this value, use the defaultItemValue() method, which requires no parameters and returns the default value as an OdTfVariant object. For example:


OdTfVariant defVal = pProp->defaultItemValue();
    

To get the current parameter value of the specified object, use the getValue() method, which requires a pointer to an OdTfObject object to specify the object with this parameter and an OdTfVariant object through which the value will be returned. For example:


pProp->getValue(pElementPtr, val);
    

The next example demonstrates dumping all properties with their name and type indices. The getAllHierarchyProperties_2() method can be found in the topic about TfClasses


pClass = pElementPtr->isA();
OdArray<const OdTfProperty*> allProperties = getAllHierarchyProperties_2(pClass);
for (OdArray<const OdTfProperty*>::iterator it = allProperties.begin(), itEnd = allProperties.end(); it != itEnd; ++it)
{
  OdString propertyName = (*it)->name();
  OdTfVariant::Type propertyType = (*it)->type();
  message.format(L"\nName %s; typeId: %d;", propertyName.c_str(), propertyType);
  pIO->putString(message);
}
    

See Also

Work with Tf Interface

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