GetNameOfPropertyEx

Returns the name of the property, if the property does not exist it returns nullptr.

Syntax

public const string EngineDLL = @"engine.dll";[DllImport(EngineDLL, EntryPoint = "GetNameOfPropertyEx")]
public static extern void GetNameOfPropertyEx(Int64 model, Int64 rdfProperty, out IntPtr name);    

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 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 name

Size: 32 bit / 4 byte (reference)
This attribute represents the name of the property; either a datatype property or a relation (given as char array / ASCII). The name is defined in space allocated by the library, this memory will be released as soon as the model is closed, or memory release is forced by CleanMemory.

Example

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

using Engine;

static void Main(string[] args)
{
    Int64 model = Engine.x86_64.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;
        Engine.x86_64.OrderedHandles(model, (IntPtr) null, out propertyCnt, (IntPtr) null, 2, 2);

        //
        //  Classes
        //
        Int64   classCollection = Engine.x86_64.GetClassByName(model, "Collection"),
                classCube = Engine.x86_64.GetClassByName(model, "Cube");

        //
        //  Object Properties (relations)
        //
        Int64   propertyAbcd = Engine.x86_64.CreateProperty(model, Engine.x86_64.OBJECTPROPERTY_TYPE, "abcd"),
                propertyObjects = Engine.x86_64.GetPropertyByName(model, "objects");
        System.Diagnostics.Debug.Assert(propertyAbcd == propertyCnt + 1);
        System.Diagnostics.Debug.Assert(propertyObjects > 0 && propertyObjects <= propertyCnt);

        //
        //  Datatype Properties (attributes)
        //
        Int64   propertyLength = Engine.x86_64.GetPropertyByName(model, "length"),
                propertyEfgh = Engine.x86_64.CreateProperty(model, Engine.x86_64.DATATYPEPROPERTY_TYPE_DOUBLE, "efgh");
        System.Diagnostics.Debug.Assert(propertyLength > 0 && propertyLength <= propertyCnt);
        System.Diagnostics.Debug.Assert(propertyEfgh == propertyCnt + 2);

        //
        //  Instances (creating)
        //
        Int64   instanceCollection = Engine.x86_64.CreateInstance(classCollection, (string) null),
                instanceCube = Engine.x86_64.CreateInstance(classCube, (string) null);

        double  length = 2.0,
                efgh = 1.7;

        Engine.x86_64.SetDatatypeProperty(instanceCube, propertyLength, ref length, 1);
        Engine.x86_64.SetDatatypeProperty(instanceCollection, propertyEfgh, ref efgh, 1);

        System.Diagnostics.Debug.Assert(Engine.x86_64.GetVolume(instanceCollection, (IntPtr) 0, (IntPtr) 0) == 0.0);

        IntPtr  propertyNamePtrI = IntPtr.Zero;
        Engine.x86_64.GetNameOfPropertyEx(model, propertyAbcd, out propertyNamePtrI);
        string propertyNameI = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(propertyNamePtrI);

        IntPtr  propertyNamePtrII = IntPtr.Zero;
        Engine.x86_64.GetNameOfPropertyEx(model, propertyEfgh, out propertyNamePtrII);
        string propertyNameII = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(propertyNamePtrII);

        Engine.x86_64.SetNameOfPropertyEx(model, propertyAbcd, "InverseRelationControledByThirdParty");

        Engine.x86_64.SetObjectProperty(instanceCube, propertyAbcd, ref instanceCollection, 1);
        Engine.x86_64.SetObjectProperty(instanceCollection, propertyObjects, ref instanceCube, 1);

        System.Diagnostics.Debug.Assert(Engine.x86_64.GetVolume(instanceCollection, (IntPtr) 0, (IntPtr) 0) == 8.0);

        IntPtr  propertyNamePtrIII = IntPtr.Zero;
        Engine.x86_64.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
        //
        Engine.x86_64.SaveModel(model, "c:\\created\\myFile.bin");
        Engine.x86_64.CloseModel(model);
    }
}