GetDatatypePropertyEx

This function gets the value(s) of a certain datatypeTypeProperty in the context of an instance.
The value of card gives the actual card of the values list.
The list values of undefined (void) items is a list of booleans, chars, integers or doubles, this list has a length as givin in the value card. The actual used type is given by the definition of the dataTypeProperty.
The return value always should be 0, if not something is wrong in the way this property is called.

This call has the same behavior as GetDatatypeProperty, however needs to be used in case properties are exchanged as a successive series of integers.

Syntax

//   Visual Studio for Windows
public:
__int64 __declspec(dllexport) __stdcall GetDatatypePropertyEx(
            __int64             model,
            __int64             owlInstance,
            __int64             rdfProperty,
            void                ** values,
            __int64             * card
        );

//   Linux, OS-X and non-Visual Studio Windows solutions
public:
int64_t GetDatatypePropertyEx(
            int64_t             model,
            int64_t             owlInstance,
            int64_t             rdfProperty,
            void                ** values,
            int64_t             * card
        );    

Property model

Size: 64 bit / 8 byte (value)
The handle to the model. The model handle is static during its existance. Several models can be opened simultaniously within one session. Different models are always independent, threads are allowed to be running on different models simultaniously.

Property owlInstance

Size: 64 bit / 8 byte (value)
The handle to the specific instance in the design tree. The instance handle is static within one open model but is most probably different when the same instance is opened in another model. The instance is always exactly of one unique class.

Property rdfProperty

Size: 64 bit / 8 byte (value)
This attribute represents a handle to the property, this can be either a datatype property (attribute), an object property (relation) or non-defined property. The handle will be static during the life-time of the model, when the model (or part of it) is saved and opened again, the handle will most probably be different.

Property values

Size: 32 bit / 4 byte (reference)
The output array for datatype properties content. The contents memory is allocated by the library

Property card

Size: 32 bit / 4 byte (reference)
The cardinality (i.e. number of elements) of the array as given or returned.

Example

Here you can find code snippits that show how the API call GetDatatypePropertyEx can be used.

#include 
#include 

int64_t model = CreateModel();

if (model) {
    //
    //  The following setting makes sure all instance handles are in an ordered list
    //  In certain cases where several models are open or in case of conversion
    //  between formats this can be handy and / or time efficient.
    //
    int64_t instanceCnt = 0;
    OrderedHandles(model, nullptr, nullptr, &instanceCnt, 4, 4);
    assert(instanceCnt == 0);

    //
    //  Classes
    //
    int64_t classAbcd = CreateClass(model, "ABCD");

    //
    //  Datatype Properties (attributes)
    //
    int64_t propertyAb = CreateProperty(model, DATATYPEPROPERTY_TYPE_BOOLEAN, "Ab"),
            propertyCd = CreateProperty(model, DATATYPEPROPERTY_TYPE_CHAR, "Cd"),
            propertyEf = CreateProperty(model, DATATYPEPROPERTY_TYPE_INTEGER, "Ef"),
            propertyGh = CreateProperty(model, DATATYPEPROPERTY_TYPE_DOUBLE, "Gh");

    //
    //  Instances
    //
    int64_t instanceAbcd = CreateInstance(classAbcd, nullptr);
    assert(instanceAbcd == instanceCnt + 1);

    //
    //  Set Properties
    //
        
    {
        bool    valuesAb[2] = { true, false };
        SetDatatypePropertyEx(model, instanceAbcd, propertyAb, valuesAb, 2);

        char    * valuesCd[2] = { "First Line", "Second Line" };
        SetDatatypePropertyEx(model, instanceAbcd, propertyCd, valuesCd, 2);

        int64_t valuesEf[2] = { 1234, 5678 };
        SetDatatypePropertyEx(model, instanceAbcd, propertyEf, valuesEf, 2);

        double  valuesGh[2] = { 12.34, 56.78 };
        SetDatatypePropertyEx(model, instanceAbcd, propertyGh, valuesGh, 2);
    }

    //
    //  Get Properties
    //

    {
        int64_t card = 0;
        bool    * values = nullptr;
        GetDatatypePropertyEx(model, instanceAbcd, propertyAb, (void**) &values, &card);

        assert(card == 2 && values[0] == true && values[1] == false);
    }

    {
        int64_t card = 0;
        char    ** values = nullptr;
        GetDatatypePropertyEx(model, instanceAbcd, propertyCd, (void**) &values, &card);

        assert(card == 2 && strcmp(values[0], "First Line") == 0 && strcmp(values[1], "Second Line") == 0);
    }

    {
        int64_t card = 0,
                * values = nullptr;
        GetDatatypePropertyEx(model, instanceAbcd, propertyEf, (void**) &values, &card);

        assert(card == 2 && values[0] == 1234 && values[1] == 5678);
    }

    {
        int64_t card = 0;
        double  * values = nullptr;
        GetDatatypePropertyEx(model, instanceAbcd, propertyGh, (void**) &values, &card);

        assert(card == 2 && values[0] == 12.34 && values[1] == 56.78);
    }

    //
    //  The same can be applied to existing classes and properties
    //

    //
    //  Classes
    //
    int64_t classCylinder = GetClassByName(model, "Cylinder");

    //
    //  Datatype Properties (attributes)
    //
    int64_t propertyClosed = GetPropertyByName(model, "closed"),
            propertyLength = GetPropertyByName(model, "length"),
            propertyName = GetPropertyByName(model, "name"),
            propertyRadius = GetPropertyByName(model, "radius"),
            propertySegmentationParts = GetPropertyByName(model, "segmentationParts");

    //
    //  Instances (creating)
    //
    int64_t myInstanceCylinder = CreateInstance(classCylinder, nullptr);
    assert(myInstanceCylinder == instanceCnt + 2);

    double  length = 1.8,
            radius = 1.3;
    int64_t segmentationParts = 36;
        
    SetDatatypePropertyEx(model, myInstanceCylinder, propertyLength, &length, 1);
    SetDatatypePropertyEx(model, myInstanceCylinder, propertyRadius, &radius, 1);
    SetDatatypePropertyEx(model, myInstanceCylinder, propertySegmentationParts, &segmentationParts, 1);

    //
    //  non related / restricted properties (user defined and pre defined) can be connected in any quantity
    //
    bool    closed = true;
    char    * name = "Example text added";

    SetDatatypePropertyEx(model, myInstanceCylinder, propertyClosed, &closed, 1);
    SetDatatypePropertyEx(model, myInstanceCylinder, propertyName, &name, 1);

    //
    //  The resulting model can be viewed in 3D-Editor.exe
    //
    SaveModel(model, "c:\\created\\myFile.bin");
    CloseModel(model);
}