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
Idof the related element. This can be added via
AdditionalPropertiesbut 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.
Levelhas a property called
Envelopecontaining the ID of an envelope produced by another function:
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
LevelVolumeelements have a relationship to the currently selected
Clicking this button reveals a menu showing these related elements and any associated View Scopes they may have:
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 a relationship is as simple as adding a property with another element's
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.