CreateInstanceWEx

Returns a handle to an on the fly created instance. If the owlClass input is zero or not a class handle 0 will be returned,

Syntax

//
//   Strong typing definition
//
OwlInstance     CreateInstanceWEx(
                        OwlModel                model,
                        OwlClass                owlClass,
                        const wchar_t           * name
                    );

static  inline  OwlInstance CreateInstanceWEx(
                                    OwlModel                model,
                                    OwlClass                owlClass,
                                    wchar_t                 * name
                                )
{
    return  CreateInstanceWEx(
                    model,
                    owlClass,
                    (const wchar_t*) name
                );
}

static  inline  OwlInstance CreateInstanceWEx(
                                    OwlModel                model,
                                    OwlClass                owlClass
                                )
{
    const wchar_t  * name = nullptr;
    return  CreateInstanceWEx(
                    model,
                    owlClass,
                    (const wchar_t*) name
                );
}


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

static  inline  int64_t CreateInstanceWEx(
                                int64_t                 model,
                                int64_t                 owlClass,
                                wchar_t                 * name
                            )
{
    return  CreateInstanceWEx(
                    model,
                    owlClass,
                    (const wchar_t*) name
                );
}

static  inline  int64_t CreateInstanceWEx(
                                int64_t                 model,
                                int64_t                 owlClass
                            )
{
    const wchar_t  * name = nullptr;
    return  CreateInstanceWEx(
                    model,
                    owlClass,
                    (const wchar_t*) 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 owlClass

Size: 64 bit / 8 byte (value)
This attribute represents a handle to the class. The term owl is comming from W3C, the classes follow the expression power of Semantic Web concepts, therefore classes support multiple inheritance. Technically classes can also be distributed over different resources, however for this the parametric library is required as an extension on the basic Geometry Kernel API.

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 CreateInstanceWEx can be used.

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

int64_t model = CreateModel();

if (model) {
    //
    //  The following setting makes sure all class handled 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 classCnt = 0;
    OrderedHandles(model, &classCnt, nullptr, nullptr, 1, 1);

    //
    //  Classes
    //
    int64_t myClass = CreateClassW(model, L"MyCreatedClass");
    assert(myClass == classCnt + 1);

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

    //
    //  Instances (creating)
    //
    int64_t myInstance = CreateInstanceWEx(model, myClass, nullptr);

    double  length = 2.;

    SetDatatypeProperty(myInstance, propertyLength, &length, 1);

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

    wchar_t * classNameI = nullptr;
    GetNameOfClassWEx(model, myClass, &classNameI);

    SetNameOfClassWEx(model, myClass, L"OtherClassName");

    wchar_t * classNameII = nullptr;
    GetNameOfClassWEx(model, myClass, &classNameII);

    SetClassParentEx(model, myClass, GetClassByNameW(model, L"Cube"), 1);

    assert(GetVolume(myInstance, 0, 0) == 8.);

    SetNameOfClassWEx(model, myClass, L"OutOfIdeasForClassName");

    wchar_t * classNameIII = nullptr;
    GetNameOfClassWEx(model, myClass, &classNameIII);

    //
    //  The retrieved class names have the following values 
    //      classNameI   :  'MyCreatedClass'
    //      classNameII  :  'OtherClassName'
    //      classNameIII :  'OutOfIdeasForClassName'
    //

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