GetDatatypeProperty
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.
Syntax
// // Strong typing definition // int64_t GetDatatypeProperty( OwlInstance owlInstance, OwlDatatypeProperty owlDatatypeProperty, const void ** values, int64_t * card ); static inline int64_t GetDatatypeProperty( OwlInstance owlInstance, OwlDatatypeProperty owlDatatypeProperty, void ** values, int64_t * card ) { return GetDatatypeProperty( owlInstance, owlDatatypeProperty, (const void**) values, card ); } // // Weak typing definition // int64_t __declspec(dllexport) __stdcall GetDatatypeProperty( int64_t owlInstance, int64_t owlDatatypeProperty, const void ** values, int64_t * card ); static inline int64_t GetDatatypeProperty( int64_t owlInstance, int64_t owlDatatypeProperty, void ** values, int64_t * card ) { return GetDatatypeProperty( owlInstance, owlDatatypeProperty, (const void**) values, card ); }
Property owlInstance
Size: 64 bit / 8 byte (value)Property owlDatatypeProperty
Size: 64 bit / 8 byte (value)Property values
Size: 32 bit / 4 byte (reference)Property card
Size: 32 bit / 4 byte (reference)
Example (based on pure API calls)
Here you can find code snippits that show how the API call GetDatatypeProperty can be used.
#include "./include/engine.h" #include <stdio.h> #include <string.h> int64_t model = CreateModel(); if (model) { // // 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); // // Set Properties // { bool valuesAb[2] = { true, false }; SetDatatypeProperty(instanceAbcd, propertyAb, valuesAb, 2); char * valuesCd[2] = { "First Line", "Second Line" }; SetDatatypeProperty(instanceAbcd, propertyCd, valuesCd, 2); int64_t valuesEf[2] = { 1234, 5678 }; SetDatatypeProperty(instanceAbcd, propertyEf, valuesEf, 2); double valuesGh[2] = { 12.34, 56.78 }; SetDatatypeProperty(instanceAbcd, propertyGh, valuesGh, 2); } // // Get Properties // { int64_t card = 0; bool * values = nullptr; GetDatatypeProperty(instanceAbcd, propertyAb, (void**) &values, &card); assert(card == 2 && values[0] == true && values[1] == false); } { int64_t card = 0; char ** values = nullptr; GetDatatypeProperty(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; GetDatatypeProperty(instanceAbcd, propertyEf, (void**) &values, &card); assert(card == 2 && values[0] == 1234 && values[1] == 5678); } { int64_t card = 0; double * values = nullptr; GetDatatypeProperty(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); double length = 1.8, radius = 1.3; int64_t segmentationParts = 36; SetDatatypeProperty(myInstanceCylinder, propertyLength, &length, 1); SetDatatypeProperty(myInstanceCylinder, propertyRadius, &radius, 1); SetDatatypeProperty(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"; SetDatatypeProperty(myInstanceCylinder, propertyClosed, &closed, 1); SetDatatypeProperty(myInstanceCylinder, propertyName, &name, 1); assert(GetArea(myInstanceCylinder, nullptr, nullptr) > 0.); // // The resulting model can be viewed in 3D-Editor.exe // SaveModel(model, "c:\\created\\myFile.bin"); CloseModel(model); }