Bench with subobjects

Versie door Renzo van Rijswijk (Overleg | bijdragen) op 12 jul 2016 om 07:42

(wijz) ← Oudere versie | Huidige versie (wijz) | Nieuwere versie → (wijz)
Ga naar: navigatie, zoeken
Sample bench
This page shows how to use the Coins-api.dll and cbim.dll for creating a Coins Contains Relation.

This sample uses the same bench as in the previous sample. In this example the bench contains of three subobjects:

  • support-left
  • support-right
  • beam

We have to tell the bench that it is both an Object and an Assembly. We call this Multi-Typing. Therefore, you can use the method addType.


Multiple typed objects can be cast to the preferred type in order to have access to functions/methods belonging to this type. The next code snippet casts a Bench object to an Assembly.

Assembly benchAsAssembly = (Assembly)bench.@as(typeof(Assembly));

Below, the relations has been programmed for the support-left only. This support-left is both an object and a part. Via the ContainsRelation the bench and the support-left are connected to each other.:

// Start container
JenaModelFactory factory = new JenaModelFactory();
JenaCoinsContainer ccr = new JenaCoinsContainer(factory, "");

// Create individual
nl.coinsweb.cbim.Object bench = new nl.coinsweb.cbim.Object(ccr);
nl.coinsweb.cbim.Object supportLeft = new nl.coinsweb.cbim.Object(ccr);
ContainsRelation crel = new ContainsRelation(ccr);

// Individual with multiple types
Assembly benchAsAssembly = (Assembly)bench.@as(typeof(Assembly));

// Configure ContainsRelation
// Set property
supportLeft.setName("Support Left Side");

// Export container

All Coins objects that are put into a Coins Container, must be typed CoinsContainerObject. Therefore, this line of code is needed: