SaveInstanceTreeS

This function saves the selected instance and its dependancies in a stream.

Syntax

public const string EngineDLL = @"engine.dll";[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void WriteCallBackFunction(IntPtr value, Int64 size);

[DllImport(EngineDLL, EntryPoint = "SaveInstanceTreeS")]
public static extern Int64 SaveInstanceTreeS(Int64 owlInstance, [MarshalAs(UnmanagedType.FunctionPtr)] WriteCallBackFunction callback, Int64 size);    

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 callback

Size: 64 bit / 8 byte (reference)
The pointer to the function that will be called within this function. Please look at the examples how to create the callback function and how it will be called. In case this is not possible or complex there is an array call, technically the same call, however the callback function is embedded within the library.

Property size

Size: 64 bit / 8 byte (value)
The (maximum) size of the content handled by the callback function.

Example

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

using Engine;

    ...

    public class OUT
    {
        public const int BLOCK_LENGTH_WRITE = 20000;    //  no maximum limit

        public FileStream fs;

        public OUT(Int64 myInstance)
        {

            // define a progress callback delegate
            Engine.x86_64.WriteCallBackFunction callback =
                (value, size) =>
                {
                    byte[] buffer = new byte[size];

                    Marshal.Copy(value, buffer, 0, (int) size);

                    fs.Write(buffer, 0, (int) size);
                };

            fs = File.Open("exportedFile.bin", FileMode.Create);

            Engine.x86_64.SaveInstanceTreeS(myModel, callback, BLOCK_LENGTH_WRITE);

            fs.Close();
        } 
    }

    ...