SetNameOfClassEx

Sets or updates the name of the class, it returns 0 on success.

Error return codes:
    0 successful
    1 argument model or owlClass is incorrect (not a proper handle to an active class)
    2 argument name is incorrect (nullptr or zero length name)
    3 the name of owlClass is locked
    4 name is already used by another class
    5 name is already used by a property
    6 name is already used by an instance
    7 undefined error

This call has the same behavior as SetNameOfClass, however needs to be used in case classes are exchanged as a successive series of integers.

Syntax

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

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

[DllImport(enginedll, EntryPoint = "SetNameOfClassEx")]
public static extern Int64 SetNameOfClassEx(Int64 model, Int64 owlClass, 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 owlClass

Size: 64 bit / 8 byte (value)
This attribute represents a handle to the class. The term owl is comming from W3C, the classes follow the expression power of Semantic Web concepts, therefore classes support multiple inheritance. Technically classes can also be distributed over different resources, however for this the parametric library is required as an extension on the basic Geometry Kernel API.

Property name

Size: 64 bit / 8 byte (reference)
This attribute represents the name of the class (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 SetNameOfClassEx 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)
    {
        //
        //  The following setting makes sure all class handled are in an ordered list
        //  In certain cases where several models are open or in case of conversion
        //  between formats this can be handy and / or time efficient.
        //
        Int64   classCnt = 0;
        RDF.engine.OrderedHandles(model, out classCnt, (IntPtr) null, (IntPtr) null, 1, 1);

        //
        //  Classes
        //
        Int64   myClass = RDF.engine.CreateClass(model, "MyCreatedClass");

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

        //
        //  Instances (creating)
        //
        Int64   myInstance = RDF.engine.CreateInstanceEx(model, myClass, (string) null);

        double  length = 2.0;

        RDF.engine.SetDatatypeProperty(myInstance, propertyLength, ref length, 1);

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

        IntPtr  classNamePtrI = IntPtr.Zero;
        RDF.engine.GetNameOfClassEx(model, myClass, out classNamePtrI);
        string classNameI = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(classNamePtrI);

        RDF.engine.SetNameOfClassEx(model, myClass, "OtherClassName");

        IntPtr  classNamePtrII = IntPtr.Zero;
        RDF.engine.GetNameOfClassEx(model, myClass, out classNamePtrII);
        string classNameII = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(classNamePtrII);

        RDF.engine.SetClassParentEx(model, myClass, RDF.engine.GetClassByName(model, "Cube"), 1);

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

        RDF.engine.SetNameOfClassEx(model, myClass, "OutOfIdeasForClassName");

        IntPtr  classNamePtrIII = IntPtr.Zero;
        RDF.engine.GetNameOfClassEx(model, myClass, out classNamePtrIII);
        string classNameIII = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(classNamePtrIII);

        //
        //  The retrieved class names have the following values 
        //      classNameI   :  'MyCreatedClass'
        //      classNameII  :  'OtherClassName'
        //      classNameIII :  'OutOfIdeasForClassName'
        //

        //
        //  The resulting model can be viewed in 3D-Editor.exe
        //
        RDF.engine.SaveModel(model, "c:\\created\\myFile.bin");
        RDF.engine.CloseModel(model);
    }
}