SetNameOfInstanceW

Sets or updates the name of the instance, it returns 0 on success.

Error return codes:
    0 successful
    1 argument owlInstance is incorrect (not a proper handle to an active instance)
    2 argument name is incorrect (nullptr or zero length name)
    3 the name of instance 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

Syntax

//
//   Strong typing definition
//
int64_t         SetNameOfInstanceW(
                        OwlInstance             owlInstance,
                        const wchar_t           * name
                    );

static  inline  int64_t SetNameOfInstanceW(
                                OwlInstance             owlInstance,
                                wchar_t                 * name
                            )
{
    return  SetNameOfInstanceW(
                    owlInstance,
                    (const wchar_t*) name
                );
}


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

static  inline  int64_t SetNameOfInstanceW(
                                int64_t                 owlInstance,
                                wchar_t                 * name
                            )
{
    return  SetNameOfInstanceW(
                    owlInstance,
                    (const wchar_t*) 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 wchar_t array / Unicode). The name is given by the host and the attribute is not changed.

Example (based on pure API calls)

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

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

int64_t model = CreateModel();

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

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

    //
    //  Instances (creating)
    //
    int64_t myInstanceI = CreateInstanceW(classCube, L""),
            myInstanceII = CreateInstanceW(classCube, L"secondInstance");

    assert(GetVolume(myInstanceI, 0, 0) == 0.);

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

    wchar_t * instanceNameI = nullptr;
    GetNameOfInstanceW(myInstanceI, &instanceNameI);

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

    wchar_t * instanceNameII = nullptr;
    GetNameOfInstanceW(myInstanceII, &instanceNameII);

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

    SetNameOfInstanceW(myInstanceI, L"firstInstance");
    SetNameOfInstanceW(myInstanceII, nullptr);

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

    assert(GetArea(myInstanceI, 0, 0) == 24.);
    assert(GetVolume(myInstanceII, 0, 0) == 27.);

    wchar_t * instanceNameIII = nullptr;
    GetNameOfInstanceW(myInstanceI, &instanceNameIII);

    wchar_t * instanceNameIV = nullptr;
    GetNameOfInstanceW(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);
}