CloseModel

This function closes the model. After this call none of the instances and classes within the model can be used anymore, also garbage collection is not allowed anymore, in default compilation the model itself will be known in the kernel, however known to be disabled. Calls containing the model reference will be protected from crashing when called.

Syntax

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

[DllImport(enginedll, EntryPoint = "CloseModel")]
public static extern Int64 CloseModel(Int64 model);    

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.

Example (based on pure API calls)

Here you can find code snippits that show how the API call CloseModel 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);
    }
}