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


public const string enginedll = @"engine.dll";

[DllImport(enginedll, EntryPoint = "GetNameOfInstanceWEx")]
public static extern IntPtr GetNameOfInstanceWEx(Int64 model, Int64 owlInstance, out IntPtr name);

public static string GetNameOfInstanceWEx(Int64 model, Int64 owlInstance)
            IntPtr name = IntPtr.Zero;
            GetNameOfInstanceWEx(model, owlInstance, out name);
            return System.Runtime.InteropServices.Marshal.PtrToStringUni(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 owlInstance

Size: 64 bit / 8 byte (value)
The handle to the specific instance in the design tree. The instance handle is static within one open model but is most probably different when the same instance is opened in another model. The instance is always exactly of one unique class.

Property name

Size: 32 bit / 4 byte (reference)
This attribute represents the name of the instance (given as wchar_t array / Unicode). 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 (based on pure API calls)

Here you can find code snippits that show how the API call GetNameOfInstanceWEx 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)
        //  Classes
        Int64   classCube = RDF.engine.GetClassByNameW(model, System.Text.Encoding.Unicode.GetBytes("Cube"));

        RDF.engine.CreateInstanceW(classCube, (string) null);
        RDF.engine.CreateInstanceW(classCube, (string) null);
        RDF.engine.CreateInstanceW(classCube, (string) null);

        //  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   instanceCnt = 0;
        RDF.engine.OrderedHandles(model, (IntPtr) 0, (IntPtr) 0, out instanceCnt, 4, 4);
        System.Diagnostics.Debug.Assert(instanceCnt == 3);

        //  Datatype Properties (attributes)
        Int64   propertyLength = RDF.engine.GetPropertyByNameW(model, System.Text.Encoding.Unicode.GetBytes("length"));

        //  Instances (creating)
        Int64   myInstanceI = RDF.engine.CreateInstanceW(classCube, System.Text.Encoding.Unicode.GetBytes("")),
                myInstanceII = RDF.engine.CreateInstanceW(classCube, System.Text.Encoding.Unicode.GetBytes("secondInstance"));
        System.Diagnostics.Debug.Assert(myInstanceI == instanceCnt + 1);
        System.Diagnostics.Debug.Assert(myInstanceII == instanceCnt + 2);

        double  length = 2.0;
        RDF.engine.SetDatatypePropertyEx(model, myInstanceI, propertyLength, ref length, 1);

        IntPtr  instanceNamePtrI = IntPtr.Zero;
        RDF.engine.GetNameOfInstanceWEx(model, myInstanceI, out instanceNamePtrI);
        string  instanceNameI = System.Runtime.InteropServices.Marshal.PtrToStringUni(instanceNamePtrI);

        length += 1.0;
        RDF.engine.SetDatatypePropertyEx(model, myInstanceII, propertyLength, ref length, 1);

        IntPtr  instanceNamePtrII = IntPtr.Zero;
        RDF.engine.GetNameOfInstanceWEx(model, myInstanceII, out instanceNamePtrII);
        string  instanceNameII = System.Runtime.InteropServices.Marshal.PtrToStringUni(instanceNamePtrII);

        RDF.engine.SetNameOfInstanceWEx(model, myInstanceI, System.Text.Encoding.Unicode.GetBytes("firstInstance"));
        RDF.engine.SetNameOfInstanceWEx(model, myInstanceII, (string) null);

        IntPtr  instanceNamePtrIII = IntPtr.Zero;
        RDF.engine.GetNameOfInstanceWEx(model, myInstanceI, out instanceNamePtrIII);
        string  instanceNameIII = System.Runtime.InteropServices.Marshal.PtrToStringUni(instanceNamePtrIII);

        IntPtr  instanceNamePtrIV = IntPtr.Zero;
        RDF.engine.GetNameOfInstanceWEx(model, myInstanceII, out instanceNamePtrIV);
        string  instanceNameIV = System.Runtime.InteropServices.Marshal.PtrToStringUni(instanceNamePtrIV);

        //  The retrieved instance names have the following values 
        //      instanceNameI   :  ''
        //      instanceNameII  :  'secondInstance'
        //      instanceNameIII :  'firstInstance'
        //      instanceNameIV  :  null

        //  The resulting model can be viewed in 3D-Editor.exe
        RDF.engine.SaveModelW(model, System.Text.Encoding.Unicode.GetBytes("c:\\created\\myFile.bin"));