CreatePropertyW

Returns a handle to an on the fly created property.
If the model input is zero or not a model handle 0 will be returned,

Syntax

public const string EngineDLL = @"engine.dll";[DllImport(EngineDLL, EntryPoint = "CreatePropertyW")]
public static extern Int64 CreatePropertyW(Int64 model, Int64 rdfPropertyType, string name);

[DllImport(EngineDLL, EntryPoint = "CreatePropertyW")]
public static extern Int64 CreatePropertyW(Int64 model, Int64 rdfPropertyType, byte[] name);    

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.

Property rdfPropertyType

Size: 64 bit / 8 byte (value)
the type of the rdfProperty, i.e. is it an ObjectProperty (relation) or a DatatypeProperty, in the later case also subdivision towards Boolean, Double, Integer or String.

Property name

Size: 64 bit / 8 byte (reference)
This attribute represents the name of the property; either a datatype property or a relation (given as wchar_t array / Unicode). The name is given by the host and the attribute is not changed.

Example

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

using Engine;

static void Main(string[] args)
{
    Int64 model = Engine.x86_64.CreateModel();

    if (model != 0)
    {
        //
        //  Classes
        //
        Int64   classCollection = Engine.x86_64.GetClassByNameW(model, System.Text.Encoding.Unicode.GetBytes("Collection")),
                classCube = Engine.x86_64.GetClassByNameW(model, System.Text.Encoding.Unicode.GetBytes("Cube"));

        //
        //  Object Properties (relations)
        //
        Int64   propertyAbcd = Engine.x86_64.CreatePropertyW(model, Engine.x86_64.OBJECTPROPERTY_TYPE, System.Text.Encoding.Unicode.GetBytes("abcd")),
                propertyObjects = Engine.x86_64.GetPropertyByNameW(model, System.Text.Encoding.Unicode.GetBytes("objects"));

        //
        //  Datatype Properties (attributes)
        //
        Int64   propertyLength = Engine.x86_64.GetPropertyByNameW(model, System.Text.Encoding.Unicode.GetBytes("length")),
                propertyEfgh = Engine.x86_64.CreatePropertyW(model, Engine.x86_64.DATATYPEPROPERTY_TYPE_DOUBLE, System.Text.Encoding.Unicode.GetBytes("efgh"));

        //
        //  Instances (creating)
        //
        Int64   instanceCollection = Engine.x86_64.CreateInstance(classCollection, (string) null),
                instanceCube = Engine.x86_64.CreateInstance(classCube, (string) null);

        double  length = 2.0,
                efgh = 1.7;

        Engine.x86_64.SetDatatypeProperty(instanceCube, propertyLength, ref length, 1);
        Engine.x86_64.SetDatatypeProperty(instanceCollection, propertyEfgh, ref efgh, 1);

        System.Diagnostics.Debug.Assert(Engine.x86_64.GetVolume(instanceCollection, (IntPtr) 0, (IntPtr) 0) == 0.0);

        IntPtr  propertyNamePtrI = IntPtr.Zero;
        Engine.x86_64.GetNameOfPropertyW(propertyAbcd, out propertyNamePtrI);
        string propertyNameI = System.Runtime.InteropServices.Marshal.PtrToStringUni(propertyNamePtrI);

        IntPtr  propertyNamePtrII = IntPtr.Zero;
        Engine.x86_64.GetNameOfPropertyW(propertyEfgh, out propertyNamePtrII);
        string propertyNameII = System.Runtime.InteropServices.Marshal.PtrToStringUni(propertyNamePtrII);

        Engine.x86_64.SetNameOfPropertyW(propertyAbcd, System.Text.Encoding.Unicode.GetBytes("InverseRelationControledByThirdParty"));

        Engine.x86_64.SetObjectProperty(instanceCube, propertyAbcd, ref instanceCollection, 1);
        Engine.x86_64.SetObjectProperty(instanceCollection, propertyObjects, ref instanceCube, 1);

        System.Diagnostics.Debug.Assert(Engine.x86_64.GetVolume(instanceCollection, (IntPtr) 0, (IntPtr) 0) == 8.0);

        IntPtr  propertyNamePtrIII = IntPtr.Zero;
        Engine.x86_64.GetNameOfPropertyW(propertyAbcd, out propertyNamePtrIII);
        string propertyNameIII = System.Runtime.InteropServices.Marshal.PtrToStringUni(propertyNamePtrIII);

        //
        //  The retrieved property names have the following values 
        //      propertyNameI   :  'abcd'
        //      propertyNameII  :  'efgh'
        //      propertyNameIII :  'InverseRelationControledByThirdParty'
        //

        //
        //  The resulting model can be viewed in 3D-Editor.exe
        //
        Engine.x86_64.SaveModelW(model, System.Text.Encoding.Unicode.GetBytes("c:\\created\\myFile.bin"));
        Engine.x86_64.CloseModel(model);
    }
}