SetNameOfPropertyEx
Error return codes:
0 successful
1 argument model or rdfProperty is incorrect (not a proper handle to an active property)
2 argument name is incorrect (nullptr or zero length name)
3 the name of rdfProperty is locked
4 name is already used by another class
5 name is already used by a property
6 name is already used by an instance
7 undefined error
This call has the same behavior as SetNameOfProperty, however needs to be
used in case properties are exchanged as a successive series of integers.
Syntax
public const string enginedll = @"engine.dll"; [DllImport(enginedll, EntryPoint = "SetNameOfPropertyEx")] public static extern Int64 SetNameOfPropertyEx(Int64 model, Int64 rdfProperty, string name); [DllImport(enginedll, EntryPoint = "SetNameOfPropertyEx")] public static extern Int64 SetNameOfPropertyEx(Int64 model, Int64 rdfProperty, byte[] name);
Property model
Size: 64 bit / 8 byte (value)Property rdfProperty
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 SetNameOfPropertyEx can be used.
using RDF; // include at least engine.cs within your solution static void Main(string[] args) { Int64 model = RDF.engine.CreateModel(); if (model != 0) { // // The following setting makes sure all properties handled 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 propertyCnt = 0; RDF.engine.OrderedHandles(model, (IntPtr) null, out propertyCnt, (IntPtr) null, 2, 2); // // Classes // Int64 classCollection = RDF.engine.GetClassByName(model, "Collection"), classCube = RDF.engine.GetClassByName(model, "Cube"); // // Object Properties (relations) // Int64 propertyAbcd = RDF.engine.CreateProperty(model, RDF.engine.OBJECTPROPERTY_TYPE, "abcd"), propertyObjects = RDF.engine.GetPropertyByName(model, "objects"); System.Diagnostics.Debug.Assert(propertyAbcd == propertyCnt + 1); System.Diagnostics.Debug.Assert(propertyObjects > 0 && propertyObjects <= propertyCnt); // // Datatype Properties (attributes) // Int64 propertyLength = RDF.engine.GetPropertyByName(model, "length"), propertyEfgh = RDF.engine.CreateProperty(model, RDF.engine.DATATYPEPROPERTY_TYPE_DOUBLE, "efgh"); System.Diagnostics.Debug.Assert(propertyLength > 0 && propertyLength <= propertyCnt); System.Diagnostics.Debug.Assert(propertyEfgh == propertyCnt + 2); // // Instances (creating) // Int64 instanceCollection = RDF.engine.CreateInstance(classCollection, (string) null), instanceCube = RDF.engine.CreateInstance(classCube, (string) null); double length = 2.0, efgh = 1.7; RDF.engine.SetDatatypeProperty(instanceCube, propertyLength, ref length, 1); RDF.engine.SetDatatypeProperty(instanceCollection, propertyEfgh, ref efgh, 1); System.Diagnostics.Debug.Assert(RDF.engine.GetVolume(instanceCollection, (IntPtr) 0, (IntPtr) 0) == 0.0); IntPtr propertyNamePtrI = IntPtr.Zero; RDF.engine.GetNameOfPropertyEx(model, propertyAbcd, out propertyNamePtrI); string propertyNameI = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(propertyNamePtrI); IntPtr propertyNamePtrII = IntPtr.Zero; RDF.engine.GetNameOfPropertyEx(model, propertyEfgh, out propertyNamePtrII); string propertyNameII = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(propertyNamePtrII); RDF.engine.SetNameOfPropertyEx(model, propertyAbcd, "InverseRelationControledByThirdParty"); RDF.engine.SetObjectProperty(instanceCube, propertyAbcd, ref instanceCollection, 1); RDF.engine.SetObjectProperty(instanceCollection, propertyObjects, ref instanceCube, 1); System.Diagnostics.Debug.Assert(RDF.engine.GetVolume(instanceCollection, (IntPtr) 0, (IntPtr) 0) == 8.0); IntPtr propertyNamePtrIII = IntPtr.Zero; RDF.engine.GetNameOfPropertyEx(model, propertyAbcd, out propertyNamePtrIII); string propertyNameIII = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(propertyNamePtrIII); // // The retrieved property names have the following values // propertyNameI : 'abcd' // propertyNameII : 'efgh' // propertyNameIII : 'InverseRelationControledByThirdParty' // // // The resulting model can be viewed in 3D-Editor.exe // RDF.engine.SaveModel(model, "c:\\created\\myFile.bin"); RDF.engine.CloseModel(model); } }