SaveInstanceTreeW

This function saves the selected instance and its dependencies on location file name.

Syntax

public const string enginedll = @"engine.dll";

[DllImport(enginedll, EntryPoint = "SaveInstanceTreeW")]
public static extern Int64 SaveInstanceTreeW(Int64 owlInstance, string fileName);

[DllImport(enginedll, EntryPoint = "SaveInstanceTreeW")]
public static extern Int64 SaveInstanceTreeW(Int64 owlInstance, byte[] 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: 32 bit / 4 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 (based on pure API calls)

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

using RDF;      //  include at least engine.cs within your solution

...

public void CreateContent()
{
    Int64   model = RDF.engine.CreateModel();

    if (model != 0)
    {
        //
        //  Classes
        //
        Int64   classBooleanOperation = RDF.engine.GetClassByName(model, "BooleanOperation"),
                classCube = RDF.engine.GetClassByName(model, "Cube"),
                classCylinder = RDF.engine.GetClassByName(model, "Cylinder"),
                classMatrix = RDF.engine.GetClassByName(model, "Matrix"),
                classTransformation = RDF.engine.GetClassByName(model, "Transformation");

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

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

        //
        //  Instances
        //
        Int64   instanceBooleanOperation = RDF.engine.CreateInstance(classBooleanOperation, (string) null),
                instanceCube = RDF.engine.CreateInstance(classCube, (string) null),
                instanceCylinder = RDF.engine.CreateInstance(classCylinder, (string) null),
                instanceMatrix = RDF.engine.CreateInstance(classMatrix, (string) null),
                instanceTransformation = RDF.engine.CreateInstance(classTransformation, (string) null);

        RDF.engine.SetObjectProperty(instanceTransformation, propertyObject, ref instanceCylinder, 1);
        RDF.engine.SetObjectProperty(instanceTransformation, propertyMatrix, ref instanceMatrix, 1);

        double  length = 1.8,
                radius = 1.3,
                offsetX = 4.2;
        Int64   segmentationParts = 36;
        
        RDF.engine.SetDatatypeProperty(instanceCylinder, propertyLength, ref length, 1);
        RDF.engine.SetDatatypeProperty(instanceCylinder, propertyRadius, ref radius, 1);
        RDF.engine.SetDatatypeProperty(instanceCylinder, propertyFirstObject, ref segmentationParts, 1);
        RDF.engine.SetDatatypeProperty(instanceMatrix, property_41, ref offsetX, 1);

        //
        //  Saves only the Transformation and (indirectly) related instances
        //
        RDF.engine.SaveInstanceTreeW(instanceTransformation, System.Text.Encoding.Unicode.GetBytes("c:\\created\\TranformedCylinder.bin"));

        RDF.engine.SetObjectProperty(instanceBooleanOperation, propertyFirstObject, ref instanceCube, 1);
        RDF.engine.SetObjectProperty(instanceBooleanOperation, propertySecondObject, ref instanceCylinder, 1);

        length = 2.1;
        Int64   type = 1;

        RDF.engine.SetDatatypeProperty(instanceCube, propertyLength, ref length, 1);
        RDF.engine.SetDatatypeProperty(instanceBooleanOperation, propertyType, ref type, 1);

        //
        //  Saves all instances
        //
        RDF.engine.SaveModelW(model, System.Text.Encoding.Unicode.GetBytes("c:\\created\\TranformedCylinderAndCubeWithSubtractedCylinder.bin"));

        //
        //  Saves only the Boolean Operation and (indirectly) related instances
        //
        RDF.engine.SaveInstanceTreeW(instanceBooleanOperation, System.Text.Encoding.Unicode.GetBytes("c:\\created\\CubeWithSubtractedCylinder.bin"));

        RDF.engine.CloseModel(model);
    }
}