CreatePropertyW
a property with this name already exists the handle of existing property will be returned.
The following reasons will cause a return value of 0:
- when the name is already used for a class or instance;
- if the model input is zero or not a model handle.
Giving the property a name is optional, if a name is not given it will recieve an automatically generated name,
it's automatically generated name can change between sessions.
Syntax
// // Strong typing definition // RdfProperty CreatePropertyW( OwlModel model, int64_t rdfPropertyType, const wchar_t * name ); static inline RdfProperty CreatePropertyW( OwlModel model, int64_t rdfPropertyType, wchar_t * name ) { return CreatePropertyW( model, rdfPropertyType, (const wchar_t*) name ); } static inline RdfProperty CreatePropertyW( OwlModel model, int64_t rdfPropertyType ) { return CreatePropertyW( model, rdfPropertyType, (const wchar_t*) nullptr // name ); } static inline RdfProperty CreatePropertyW( OwlModel model ) { return CreatePropertyW( model, 0, // rdfPropertyType (const wchar_t*) nullptr // name ); } // // Weak typing definition // int64_t __declspec(dllexport) __stdcall CreatePropertyW( int64_t model, int64_t rdfPropertyType, const wchar_t * name ); static inline int64_t CreatePropertyW( int64_t model, int64_t rdfPropertyType, wchar_t * name ) { return CreatePropertyW( model, rdfPropertyType, (const wchar_t*) name ); } static inline int64_t CreatePropertyW( int64_t model, int64_t rdfPropertyType ) { return CreatePropertyW( model, rdfPropertyType, (const wchar_t*) nullptr // name ); } static inline int64_t CreatePropertyW( int64_t model ) { return CreatePropertyW( model, 0, // rdfPropertyType (const wchar_t*) nullptr // name ); }
Property model
Size: 64 bit / 8 byte (value)Property rdfPropertyType
Size: 64 bit / 8 byte (value)Property name
Size: 64 bit / 8 byte (reference)
Example (based on pure API calls)
Here you can find code snippits that show how the API call CreatePropertyW can be used.
#include "./include/engine.h" #include <cmath> int64_t model = CreateModel(); if (model) { // // Classes // int64_t classCollection = GetClassByNameW(model, L"Collection"), classCube = GetClassByNameW(model, L"Cube"); // // Object Properties (relations) // int64_t propertyAbcd = CreatePropertyW(model, OBJECTPROPERTY_TYPE, L"abcd"), propertyObjects = GetPropertyByNameW(model, L"objects"); // // Datatype Properties (attributes) // int64_t propertyLength = GetPropertyByNameW(model, L"length"), propertyEfgh = CreatePropertyW(model, DATATYPEPROPERTY_TYPE_DOUBLE, L"efgh"); // // Instances (creating) // int64_t instanceCollection = CreateInstance(classCollection, nullptr), instanceCube = CreateInstance(classCube, nullptr); double length = 2., efgh = 1.7; SetDatatypeProperty(instanceCube, propertyLength, &length, 1); SetDatatypeProperty(instanceCollection, propertyEfgh, &efgh, 1); assert(GetVolume(instanceCollection, 0, 0) == 0.); wchar_t * propertyNameI = nullptr; GetNameOfPropertyW(propertyAbcd, &propertyNameI); wchar_t * propertyNameII = nullptr; GetNameOfPropertyW(propertyEfgh, &propertyNameII); SetNameOfPropertyW(propertyAbcd, L"InverseRelationControledByThirdParty"); SetObjectProperty(instanceCube, propertyAbcd, &instanceCollection, 1); SetObjectProperty(instanceCollection, propertyObjects, &instanceCube, 1); assert(GetVolume(instanceCollection, 0, 0) == 8.); wchar_t * propertyNameIII = nullptr; GetNameOfPropertyW(propertyAbcd, &propertyNameIII); // // The retrieved property names have the following values // propertyNameI : 'abcd' // propertyNameII : 'efgh' // propertyNameIII : 'InverseRelationControledByThirdParty' // // // The resulting model can be viewed in 3D-Editor.exe // SaveModelW(model, L"c:\\created\\myFile.bin"); CloseModel(model); }