SetClassParentEx

Defines (set/unset) the parent class of a given class. Multiple-inheritence is supported and behavior of parent classes is also inherited as well as cardinality restrictions on datatype properties and object properties (relations).

This call has the same behavior as SetClassParent, 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 = "SetClassParentEx")]
public static extern void SetClassParentEx(Int64 model, Int64 owlClass, Int64 parentOwlClass, Int64 setting);    

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 parentOwlClass

Size: 64 bit / 8 byte (value)
This attribute represents a handle to the parent class.

Property setting

Size: 64 bit / 8 byte (value)
The setting is the data that is defined for bitwise operations, only bits set in the mask will be relevant.

Example

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

using Engine;

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

    if (model != 0)
    {
        Int64   classCnt = 0, propertyCnt = 0, instanceCnt = 0;
        Engine.x86_64.OrderedHandles(model, out classCnt, out propertyCnt, out instanceCnt, 1 + 2 + 4, 1 + 2 + 4);
        System.Diagnostics.Debug.Assert(instanceCnt == 0);

        //
        //  The following class will be created on-the-fly if the name is not used already
        //  for a class or property (attribute / relation).
        //
        //  note: calling GetClassByName with a name not yet existing will do the same trick)
        //
        Int64   classMyOwnCylinderClass = Engine.x86_64.CreateClass(model, "MyOwnCylinderClass");
        System.Diagnostics.Debug.Assert(classMyOwnCylinderClass == classCnt + 1);   //  references are never 0, therefore classes, properties and instances start at 1

        //
        //  Classes
        //
        Int64   classCylinder = Engine.x86_64.GetClassByName(model, "Cylinder");
        System.Diagnostics.Debug.Assert(classCylinder > 0 && classCylinder <= classCnt);

        //
        //  Datatype Properties (attributes)
        //
        Int64   propertyLength = Engine.x86_64.GetPropertyByName(model, "length"),
                propertyRadius = Engine.x86_64.GetPropertyByName(model, "radius"),
                propertySegmentationParts = Engine.x86_64.GetPropertyByName(model, "segmentationParts");
        System.Diagnostics.Debug.Assert(propertyLength > 0 && propertyLength <= propertyCnt);
        System.Diagnostics.Debug.Assert(propertyRadius > 0 && propertyRadius <= propertyCnt);
        System.Diagnostics.Debug.Assert(propertySegmentationParts > 0 && propertySegmentationParts <= propertyCnt);

        //
        //  Instances
        //
        Int64   instanceMyOwnCylinderClass = Engine.x86_64.CreateInstanceEx(model, classMyOwnCylinderClass, (string) null);
        System.Diagnostics.Debug.Assert(instanceMyOwnCylinderClass == 1);

        //
        //  At this moment our new class is unrelated to other classes and instances of it not generating any geometry
        //
        System.Diagnostics.Debug.Assert(Engine.x86_64.GetGeometryClassEx(model, classMyOwnCylinderClass) == 0);

        Engine.x86_64.SetClassParentEx(model, classMyOwnCylinderClass, classCylinder, 1);

        //
        //  Now each instance of MyOwnCylinderClass is inheriting the behavior and knowledge of a Cylinder
        //
        System.Diagnostics.Debug.Assert(Engine.x86_64.GetGeometryClassEx(model, classMyOwnCylinderClass) == classCylinder);

        double  length = 1.8,
                radius = 1.3;
        Int64   segmentationParts = 36;
        
        Engine.x86_64.SetDatatypePropertyEx(model, instanceMyOwnCylinderClass, propertyLength, ref length, 1);
        Engine.x86_64.SetDatatypePropertyEx(model, instanceMyOwnCylinderClass, propertyRadius, ref radius, 1);
        Engine.x86_64.SetDatatypePropertyEx(model, instanceMyOwnCylinderClass, propertySegmentationParts, ref segmentationParts, 1);

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