Element Types

Getting started

Core concepts


The primary concept behind Elements types is the Element. An Element is the base type for all things that you will create. It has a unique identifier and a name. That's it. Everything else will be added by you.


An Element is extended by adding properties to a schema. The properties can be of the following types.
  • Curve
    • Arc - An arc defined by a center and a radius.
    • Line - A line defined by a start and end points.
    • Polygon - A collection of vertices describing an enclosed polygonal shape.
  • NumericProperty - A property value with a unit type.
  • Plane - A plane described by its origin and normal vector.
  • Profile - A composite type containing a perimeter Polygon and a collection of Polygon
  • Representation - A container for solid operations like Extrude and Sweep.
  • Transform - A right-handed coordinate system with +Z "up".
  • Vector3 - A vector with x, y, and z components.

Create a Type

The first step is to define a schema that represents your type. Good examples for what a schema looks like can be found in the Hypar base schemas. Here's the schema for GeometricElement, a type which extends Element to include a Transform and a Representation.
JSON schemas can be authored in any text editor, although an editor with good JSON schema support, like Visual Studio Code, is recommended. Good editors have built in JSON schema validation and code completion. You can also use an online validator.

An example Beam

The following schema describes a simple beam with a center line and a cross-section profile. Note that using the allOf field, we can inherit from GeometricElement so that a Beam will extend that base type.
{ "$id": "https://hypar.io/Schemas/Beam.json", "$schema": "http://json-schema.org/draft-07/schema#", "description": "A beam.", "title": "Beam", "x-namespace": "Elements", "type": ["object", "null"], "allOf": [{"$ref": "https://hypar.io/Schemas/GeometricElement.json"}], "required": ["CenterLine", "Profile"], "properties": { "CenterLine": { "description": "The center line of the beam.", "$ref": "https://hypar.io/Schemas/Geometry/Line.json" }, "Profile": { "description": "The beam's cross section.", "$ref": "https://hypar.io/Schemas/Geometry/Profile.json" } }, "additionalProperties": false }

Generate code for your Type

The Hypar CLI can be used to generate code for your type.
plain text
hypar generate-types -u ./beam.json -o ./Structural

Generate code for your Hypar Function

You can specify that your Hypar function requires additional types by declaring those types in the element_types property of the hypar.json. The element_types array contains uris, either as relative file paths or urls to JSON schemas representing types. When you run hypar init code will be generated from each of the schemas specified in the element_types array and placed in your function's /dependencies directory.
You can also use the UI to add types to your function, don’t forget to use hypar pull after you make edits in the web UI.
Image without caption

Powered by Notaku