SetDatatypePropertyEx
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 given in the values 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 SetDatatypeProperty, however needs to be
used in case properties are exchanged as a successive series of integers.
Note: the client application needs to make sure the cardinality of
the property is within the boundaries.
Syntax
// // Strong typing definition // int64_t SetDatatypePropertyEx( OwlModel model, OwlInstance owlInstance, OwlDatatypeProperty owlDatatypeProperty, const void * values, int64_t card ); // // Weak typing definition // int64_t __declspec(dllexport) __stdcall SetDatatypePropertyEx( int64_t model, int64_t owlInstance, int64_t owlDatatypeProperty, const void * values, int64_t card );
Property model
Size: 64 bit / 8 byte (value)Property owlInstance
Size: 64 bit / 8 byte (value)Property owlDatatypeProperty
Size: 64 bit / 8 byte (value)Property values
Size: 64 bit / 8 byte (reference)Property card
Size: 64 bit / 8 byte (value)
Example (based on pure API calls)
Here you can find code snippits that show how the API call SetDatatypePropertyEx can be used.
#include "./include/engine.h" #include <stdio.h> #include <string.h> 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); }