SetNameOfInstanceEx

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

Error return codes:
    0 successful
    1 argument model or 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

This call has the same behavior as SetNameOfInstance, however needs to be used in case instance are exchanged as a successive series of integers.

Syntax

//
//   Strong typing definition
//
int64_t         SetNameOfInstanceEx(
                        OwlModel                model,
                        OwlInstance             owlInstance,
                        const char              * name
                    );

static  inline  int64_t SetNameOfInstanceEx(
                                OwlModel                model,
                                OwlInstance             owlInstance,
                                char                    * name
                            )
{
    return  SetNameOfInstanceEx(
                    model,
                    owlInstance,
                    (const char*) name
                );
}


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

static  inline  int64_t SetNameOfInstanceEx(
                                int64_t                 model,
                                int64_t                 owlInstance,
                                char                    * name
                            )
{
    return  SetNameOfInstanceEx(
                    model,
                    owlInstance,
                    (const char*) 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 char array / ASCII). 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 SetNameOfInstanceEx can be used.

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

int64_t model = CreateModel();

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

    CreateInstance(classCube, nullptr);
    CreateInstance(classCube, nullptr);
    CreateInstance(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 = GetPropertyByName(model, "length");

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

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

    char    * instanceNameI = nullptr;
    GetNameOfInstanceEx(model, myInstanceI, &instanceNameI);

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

    char    * instanceNameII = nullptr;
    GetNameOfInstanceEx(model, myInstanceII, &instanceNameII);

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

    SetNameOfInstanceEx(model, myInstanceI, "firstInstance");
    SetNameOfInstanceEx(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)
    //

    char    * instanceNameIII = nullptr;
    GetNameOfInstanceEx(model, myInstanceI, &instanceNameIII);

    char    * instanceNameIV = nullptr;
    GetNameOfInstanceEx(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
    //
    SaveModel(model, "c:\\created\\myFile.bin");
    CloseModel(model);
}