GetNameOfInstance

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

Syntax

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

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: 64 bit / 8 byte (reference)
This attribute represents the name of the instance (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 GetNameOfInstance can be used.

using Engine;

static void Main(string[] args)
{
    Int64 model = Engine.x86_64.CreateModel();

    if (model != 0)
    {
        //
        //  Classes
        //
        Int64   classCube = Engine.x86_64.GetClassByName(model, "Cube");

        //
        //  Datatype Properties (attributes)
        //
        Int64   propertyLength = Engine.x86_64.GetPropertyByName(model, "length");

        //
        //  Instances (creating)
        //
        Int64   myInstanceI = Engine.x86_64.CreateInstance(classCube, ""),
                myInstanceII = Engine.x86_64.CreateInstance(classCube, "secondInstance");

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

        double  length = 2.0;
        Engine.x86_64.SetDatatypeProperty(myInstanceI, propertyLength, ref length, 1);

        IntPtr  instanceNamePtrI = IntPtr.Zero;
        Engine.x86_64.GetNameOfInstance(myInstanceI, out instanceNamePtrI);
        string  instanceNameI = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(instanceNamePtrI);

        length += 1.0;
        Engine.x86_64.SetDatatypeProperty(myInstanceII, propertyLength, ref length, 1);

        IntPtr  instanceNamePtrII = IntPtr.Zero;
        Engine.x86_64.GetNameOfInstance(myInstanceII, out instanceNamePtrII);
        string  instanceNameII = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(instanceNamePtrII);

        Engine.x86_64.SetNameOfInstance(myInstanceI, "firstInstance");
        Engine.x86_64.SetNameOfInstance(myInstanceII, (string) null);

        System.Diagnostics.Debug.Assert(Engine.x86_64.GetArea(myInstanceI, (IntPtr) 0, (IntPtr) 0) == 24.0);
        System.Diagnostics.Debug.Assert(Engine.x86_64.GetVolume(myInstanceII, (IntPtr) 0, (IntPtr) 0) == 27.0);

        IntPtr  instanceNamePtrIII = IntPtr.Zero;
        Engine.x86_64.GetNameOfInstance(myInstanceI, out instanceNamePtrIII);
        string  instanceNameIII = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(instanceNamePtrIII);

        IntPtr  instanceNamePtrIV = IntPtr.Zero;
        Engine.x86_64.GetNameOfInstance(myInstanceII, out instanceNamePtrIV);
        string  instanceNameIV = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(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
        //
        Engine.x86_64.SaveModel(model, "c:\\created\\myFile.bin");
        Engine.x86_64.CloseModel(model);
    }
}