Element Instances

What are Element Instances?

Element instances are a mechanism provided with Elements to create lightweight copies of a base element, so that the copies can be generated and displayed efficiently. If you're making many copies of an item of furniture or other repeated element, you should consider utilizing element instances.

How do you create Element Instances?

Any element type which inherits from GeometricElement can be the "base definition" for an element instance. In order for it to serve this purpose, the element you want to make instances from must have its IsElementDefinition property set to true.
var baseElement = new Column((0, 0, 0), 3, Polygon.Ngon(6, 0.5)) { IsElementDefinition = true };
πŸ’‘
Elements with IsElementDefinition = true will not show in the model themselves. You'll need to create instances of these elements to see anything in the Hypar web UI.
Then, we can create multiple instances of it using .CreateInstance(), supplying a transform and a name:
for (int i = 0; i < 10; i++) { var location = (i * 2, 0, 0); var transform = new Transform(location); var instance = baseElement.CreateInstance(transform, $"Instance {i}"); output.Model.AddElement(instance); }
Now our model contains 10 lightweight instances of the same hexagonal column.
Β 

Instances of Content Elements

It is often useful to create instances of detailed elements created in other software, like items of furniture. ContentElements are designed for this purpose: see
πŸͺ‘
Content Elements
for details.