GetNameOfInstance

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

Syntax

//
//   Strong typing definition
//
const char      * GetNameOfInstance(
                        OwlInstance             owlInstance,
                        const char              ** name
                    );

static  inline  const char  * GetNameOfInstance(
                                    OwlInstance             owlInstance,
                                    char                    ** name
                                )
{
    return  GetNameOfInstance(
                    owlInstance,
                    (const char**) name
                );
}

static  inline  const char  * GetNameOfInstance(
                                    OwlInstance             owlInstance
                                )
{
    return  GetNameOfInstance(
                    owlInstance,
                    (const char**) nullptr              //    name
                );
}


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

static  inline  const char  * GetNameOfInstance(
                                    int64_t                 owlInstance,
                                    char                    ** name
                                )
{
    return  GetNameOfInstance(
                    owlInstance,
                    (const char**) name
                );
}

static  inline  const char  * GetNameOfInstance(
                                    int64_t                 owlInstance
                                )
{
    return  GetNameOfInstance(
                    owlInstance,
                    (const char**) nullptr              //    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 (based on pure API calls)

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

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

int64_t model = CreateModel();

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

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

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

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

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

    char    * instanceNameI = nullptr;
    GetNameOfInstance(myInstanceI, &instanceNameI);

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

    char    * instanceNameII = nullptr;
    GetNameOfInstance(myInstanceII, &instanceNameII);

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

    SetNameOfInstance(myInstanceI, "firstInstance");
    SetNameOfInstance(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.);

    char    * instanceNameIII = nullptr;
    GetNameOfInstance(myInstanceI, &instanceNameIII);

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