logo

Element Relationships

Often, elements in a model will have natural relationships to one another. For example, a level has a relationship to the building it belongs to, and a piece of furniture has a relationship to the room its in, or the floor it's on.
These relationships are expressed very simply in Hypar Elements: by storing a property containing the Id of the related element. This can be added via AdditionalProperties but if it's a natural relationship for the element to have, it should probably be encoded in the element's schema.
If an element specifies a relationship to another, that surfaces in the UI in the following ways.
This Level has a property called Envelope containing the ID of an envelope produced by another function:
Image without caption
Clicking that button will select the envelope in question.
Relationships are implicitly bi-directional β€” if element A has a relationship to B, B doesn't need to specify its own separate relationship to A. Selecting B will show the relationship back to A automatically. For instance, four LevelVolume elements have a relationship to the currently selected Envelope:
Image without caption
Clicking this button reveals a menu showing these related elements and any associated πŸŽ₯View Scopes they may have:
Image without caption
Relationships also show up in Elements Tables, in the Outputs panel or added to the workspace as Widgets. Clicking a relationship selects the element in the 3D workspace, as well as in any open tables displaying that element.

Adding relationships to elements you create

Adding a relationship is as simple as adding a property with another element's Id.
c#
Envelope envelope = inputModels["Envelope"].AllElementsOfType<Envelope>().First(); LevelVolume level = new LevelVolume(); level.AdditionalProperties["Envelope"] = envelope.Id;
See Building Blocks for more examples of element relationships.
πŸ–‡οΈAnnotated Relationships with $hyparRelationship