SaveInstanceTreeW

This function saves the selected instance and its dependancies on location fileName.

Syntax

//   Visual Studio for Windows
public:
__int64 __declspec(dllexport) __stdcall SaveInstanceTreeW(
            __int64             owlInstance,
            const wchar_t       * fileName
        );

//   Linux, OS-X and non-Visual Studio Windows solutions
public:
int64_t SaveInstanceTreeW(
            int64_t             owlInstance,
            const wchar_t       * fileName
        );    

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 fileName

Size: 64 bit / 8 byte (reference)
The file name of the file as available in the file system in Unicode (wchar_t *). The given wchar_t array will not be adjusted. The size of each wchar_t element is depending on the OS, both 16 bit / 2 bytes wchar_t elements as well as 32 bit / 4 byte wchar_t elements are recognized and supported.

Example

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

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

void    CreateContent()
{
    int64_t model = CreateModel();

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

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

        //
        //  Datatype Properties (attributes)
        //
        int64_t property_41 = GetPropertyByName(model, "_41"),
                propertyLength = GetPropertyByName(model, "length"),
                propertyRadius = GetPropertyByName(model, "radius"),
                propertySegmentationParts = GetPropertyByName(model, "segmentationParts"),
                propertyType = GetPropertyByName(model, "type");

        //
        //  Instances
        //
        int64_t instanceBooleanOperation = CreateInstance(classBooleanOperation, nullptr),
                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  length = 1.8,
                radius = 1.3,
                offsetX = 4.2;
        int64_t segmentationParts = 36;
        
        SetDatatypeProperty(instanceCylinder, propertyLength, &length, 1);
        SetDatatypeProperty(instanceCylinder, propertyRadius, &radius, 1);
        SetDatatypeProperty(instanceCylinder, propertyFirstObject, &segmentationParts, 1);
        SetDatatypeProperty(instanceMatrix, property_41, &offsetX, 1);

        //
        //  Saves only the Transformation and (indirectly) related instances
        //
        SaveInstanceTreeW(instanceTransformation, L"c:\\created\\TranformedCylinder.bin");

        SetObjectProperty(instanceBooleanOperation, propertyFirstObject, &instanceCube, 1);
        SetObjectProperty(instanceBooleanOperation, propertySecondObject, &instanceCylinder, 1);

        length = 2.1;
        int64_t type = 1;

        SetDatatypeProperty(instanceCube, propertyLength, &length, 1);
        SetDatatypeProperty(instanceBooleanOperation, propertyType, &type, 1);

        //
        //  Saves all instances
        //
        SaveModelW(model, L"c:\\created\\TranformedCylinderAndCubeWithSubtractedCylinder.bin");

        //
        //  Saves only the Boolean Operation and (indirectly) related instances
        //
        SaveInstanceTreeW(instanceBooleanOperation, L"c:\\created\\CubeWithSubtractedCylinder.bin");

        CloseModel(model);
    }
}