CreateProperty

Returns a handle to an on the fly created property, however when
a property with this name already exists the handle of existing property will be returned.

The following reasons will cause a return value of 0:
    - when the name is already used for a class or instance;
    - if the model input is zero or not a model handle.

Giving the property a name is optional, if a name is not given it will receive an automatically generated name,
it's automatically generated name can change between sessions.

Syntax

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

[DllImport(enginedll, EntryPoint = "CreateProperty")]
public static extern Int64 CreateProperty(Int64 model, Int64 rdfPropertyType, string name);

[DllImport(enginedll, EntryPoint = "CreateProperty")]
public static extern Int64 CreateProperty(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: 32 bit / 4 byte (reference)
This attribute represents the name of the property; either a datatype property or a relation (given as char array / ASCII). The name is given by the host and the attribute is not changed.

Example (based on pure API calls)

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

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

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

    if (model != 0)
    {
        //
        //  Classes
        //
        Int64   classCollection = RDF.engine.GetClassByName(model, "Collection"),
                classCube = RDF.engine.GetClassByName(model, "Cube");

        //
        //  Object Properties (relations)
        //
        Int64   propertyAbcd = RDF.engine.CreateProperty(model, RDF.engine.OBJECTPROPERTY_TYPE, "abcd"),
                propertyObjects = RDF.engine.GetPropertyByName(model, "objects");

        //
        //  Datatype Properties (attributes)
        //
        Int64   propertyLength = RDF.engine.GetPropertyByName(model, "length"),
                propertyEfgh = RDF.engine.CreateProperty(model, RDF.engine.DATATYPEPROPERTY_TYPE_DOUBLE, "efgh");

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

        double  length = 2.0,
                efgh = 1.7;

        RDF.engine.SetDatatypeProperty(instanceCube, propertyLength, ref length, 1);
        RDF.engine.SetDatatypeProperty(instanceCollection, propertyEfgh, ref efgh, 1);

        System.Diagnostics.Debug.Assert(RDF.engine.GetVolume(instanceCollection, (IntPtr) 0, (IntPtr) 0) == 0.0);

        IntPtr  propertyNamePtrI = IntPtr.Zero;
        RDF.engine.GetNameOfProperty(propertyAbcd, out propertyNamePtrI);
        string propertyNameI = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(propertyNamePtrI);

        IntPtr  propertyNamePtrII = IntPtr.Zero;
        RDF.engine.GetNameOfProperty(propertyEfgh, out propertyNamePtrII);
        string propertyNameII = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(propertyNamePtrII);

        RDF.engine.SetNameOfProperty(propertyAbcd, "InverseRelationControledByThirdParty");

        RDF.engine.SetObjectProperty(instanceCube, propertyAbcd, ref instanceCollection, 1);
        RDF.engine.SetObjectProperty(instanceCollection, propertyObjects, ref instanceCube, 1);

        System.Diagnostics.Debug.Assert(RDF.engine.GetVolume(instanceCollection, (IntPtr) 0, (IntPtr) 0) == 8.0);

        IntPtr  propertyNamePtrIII = IntPtr.Zero;
        RDF.engine.GetNameOfProperty(propertyAbcd, out propertyNamePtrIII);
        string propertyNameIII = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(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
        //
        RDF.engine.SaveModel(model, "c:\\created\\myFile.bin");
        RDF.engine.CloseModel(model);
    }
}