GetNameOfInstanceWEx

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

Syntax

//
//   Strong typing definition
//
const wchar_t   * GetNameOfInstanceWEx(
                        OwlModel                model,
                        OwlInstance             owlInstance,
                        const wchar_t           ** name
                    );

static  inline  const wchar_t   * GetNameOfInstanceWEx(
                                        OwlModel                model,
                                        OwlInstance             owlInstance,
                                        wchar_t                 ** name
                                    )
{
    return  GetNameOfInstanceWEx(
                    model,
                    owlInstance,
                    (const wchar_t**) name
                );
}

static  inline  const wchar_t   * GetNameOfInstanceWEx(
                                        OwlModel                model,
                                        OwlInstance             owlInstance
                                    )
{
    return  GetNameOfInstanceWEx(
                    model,
                    owlInstance,
                    (const wchar_t**) nullptr           //    name
                );
}


//
//   Weak typing definition
//
const wchar_t   __declspec(dllexport) * __stdcall   GetNameOfInstanceWEx(
                                                            int64_t                 model,
                                                            int64_t                 owlInstance,
                                                            const wchar_t           ** name
                                                        );

static  inline  const wchar_t   * GetNameOfInstanceWEx(
                                        int64_t                 model,
                                        int64_t                 owlInstance,
                                        wchar_t                 ** name
                                    )
{
    return  GetNameOfInstanceWEx(
                    model,
                    owlInstance,
                    (const wchar_t**) name
                );
}

static  inline  const wchar_t   * GetNameOfInstanceWEx(
                                        int64_t                 model,
                                        int64_t                 owlInstance
                                    )
{
    return  GetNameOfInstanceWEx(
                    model,
                    owlInstance,
                    (const wchar_t**) nullptr           //    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: 64 bit / 8 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.

#include    "./include/engine.h"
#include    <cmath>

int64_t model = CreateModel();

if (model) {
    //
    //  Classes
    //
    int64_t classCube = GetClassByNameW(model, L"Cube");

    CreateInstanceW(classCube, nullptr);
    CreateInstanceW(classCube, nullptr);
    CreateInstanceW(classCube, nullptr);

    //
    //  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_t instanceCnt = 0;
    OrderedHandles(model, nullptr, nullptr, &instanceCnt, 4, 4);
    assert(instanceCnt == 3);

    //
    //  Datatype Properties (attributes)
    //
    int64_t propertyLength = GetPropertyByNameW(model, L"length");

    //
    //  Instances (creating)
    //
    int64_t myInstanceI = CreateInstanceW(classCube, L""),
            myInstanceII = CreateInstanceW(classCube, L"secondInstance");
    assert(myInstanceI == instanceCnt + 1);
    assert(myInstanceII == instanceCnt + 2);

    double  length = 2.;
    SetDatatypePropertyEx(model, myInstanceI, propertyLength, &length, 1);

    wchar_t * instanceNameI = nullptr;
    GetNameOfInstanceWEx(model, myInstanceI, &instanceNameI);

    length += 1.;
    SetDatatypePropertyEx(model, myInstanceII, propertyLength, &length, 1);

    wchar_t * instanceNameII = nullptr;
    GetNameOfInstanceWEx(model, myInstanceII, &instanceNameII);

    //
    //  The retrieved instance names have the following values 
    //      instanceNameI   :  ''
    //      instanceNameII  :  'secondInstance'
    //

    SetNameOfInstanceWEx(model, myInstanceI, L"firstInstance");
    SetNameOfInstanceWEx(model, myInstanceII, nullptr);

    //
    //  The retrieved instance names have the following values 
    //      instanceNameI   :  UNDEFINED (name is not anymore existing)
    //      instanceNameII  :  UNDEFINED (name is not anymore existing)
    //

    wchar_t * instanceNameIII = nullptr;
    GetNameOfInstanceWEx(model, myInstanceI, &instanceNameIII);

    wchar_t * instanceNameIV = nullptr;
    GetNameOfInstanceWEx(model, myInstanceII, &instanceNameIV);

    //
    //  The retrieved instance names have the following values 
    //      instanceNameI   :  UNDEFINED (name is not anymore existing)
    //      instanceNameII  :  UNDEFINED (name is not anymore existing)
    //      instanceNameIII :  'firstInstance'
    //      instanceNameIV  :  nullptr
    //

    //
    //  The resulting model can be viewed in 3D-Editor.exe
    //
    SaveModelW(model, L"c:\\created\\myFile.bin");
    CloseModel(model);
}