RemoveInstanceRecursively

This function removes an instance recursively from the internal structure.
In case checkInverseRelations is non-zero only instances that are not referenced by other existing instances.

Return value is total number of removed instances

Syntax

//   Visual Studio for Windows
public:
__int64 __declspec(dllexport) __stdcall RemoveInstanceRecursively(
            __int64             owlInstance
        );

//   Linux, OS-X and non-Visual Studio Windows solutions
public:
int64_t RemoveInstanceRecursively(
            int64_t             owlInstance
        );    

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.

Example

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

int64_t model = CreateModel();

if (model) {
    //
    //  Classes
    //
    int64_t classCube = GetClassByName(model, "Cube"),
            classCylinder = GetClassByName(model, "Cylinder"),
            classMatrix = GetClassByName(model, "Matrix"),
            classTransformation = GetClassByName(model, "Transformation");

    //
    //  Object Properties (relations)
    //
    int64_t propertyMatrix = GetPropertyByName(model, "matrix"),
            propertyObject = GetPropertyByName(model, "object");

    //
    //  Datatype Properties (attributes)
    //
    int64_t property_42 = GetPropertyByName(model, "_42"),
            propertyLength = GetPropertyByName(model, "length"),
            propertyRadius = GetPropertyByName(model, "radius");

    //
    //  Instances (creating)
    //
    int64_t instanceCube = CreateInstance(classCube, nullptr),
            instanceCylinder = CreateInstance(classCylinder, nullptr),
            instanceMatrix = CreateInstance(classMatrix, nullptr),
            instanceTransformation = CreateInstance(classTransformation, nullptr);

    SetObjectProperty(instanceTransformation, propertyObject, &instanceCylinder, 1);
    SetObjectProperty(instanceTransformation, propertyMatrix, &instanceMatrix, 1);

    double  lengthCube = 2.1,
            lengthCyl = 2.8,
            radiusCyl = 1.3,
            offsetY = -1.2;

    SetDatatypeProperty(instanceCube, propertyLength, &lengthCube, 1);
    SetDatatypeProperty(instanceCylinder, propertyLength, &lengthCyl, 1);
    SetDatatypeProperty(instanceCylinder, propertyRadius, &radiusCyl, 1);
    SetDatatypeProperty(instanceMatrix, property_42, &offsetY, 1);

    int64_t instanceCnt = 0;
    OrderedHandles(model, nullptr, nullptr, &instanceCnt, 0, 0);
    assert(instanceCnt == 4);

    RemoveInstanceRecursively(instanceCylinder);    //  this will not remove the Cylinder instance as it is referenced
    
    OrderedHandles(model, nullptr, nullptr, &instanceCnt, 0, 0);
    assert(instanceCnt == 4);

    RemoveInstanceRecursively(instanceTransformation);

    OrderedHandles(model, nullptr, nullptr, &instanceCnt, 0, 0);
    assert(instanceCnt == 1);

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