This is a generator. A generator is a function which receives a Model
, does some compute, and returns a Model
. Generators can take additional inputs
, and output additional outputs
as well.
By managing your generator as code, you can take advantage of all the great tools for code collaboration and deployment offered by GitHub. Like any good repo, your generator should have a great README.md
(like this one) which acts as the documentation for your generator. If you look below, you'll see that this README.md
contains a short description of what kind of output your generator creates. Over time we're going to automate the creation of a preview image, like the one you see below, which'll give you a good idea of what you should expect to see from a generator.
Generators are just code, so you're free to compile and run them wherever they're compatible. This generator is a .Net Standard 2.0 library written in C# which means you can use it in a Revit addin, a Unity app, or as a "zero touch" library in Dynamo. But if you really want to put your generator to work, you can publish it to run on the Hypar platform, making it globally available and executable via Hypar's API. You can see this generator running here.
The Elements library is at the heart of the Hypar platform. You author the generator logic referencing the Elements library, and publish the generator to Hypar, then Hypar executes it for you and stores the results. Here's a very high level diagram of what happens:
You can see some generators written using Hypar Elements running on Hypar. Hypar is just one example of a business that can be built on top of this tool. We fully expect you'll go and build your own cool thing.
- Go to https://www.hypar.io/ and sign up.
- Install .NET
- Install a good integrated development environment (IDE). We recommend Visual Studio Code with the C# for Visual Studio Code Extension. Visual Studio Community is also a great choice.
- Install the Hypar CLI:
- Create a generator.
hypar init <generator id>
This will clone the generator repo to the folder <generator id>
. Of course, you can replace <generator-id>
with anything you like. The generator project is a buildable .net class library which references the Elements NuGet package.
- Edit the
hypar.json
. Thehypar.json
file describes the interface for your generator. A the top of thehypar.json
file, thehypar-schema
is referenced. In Visual Studio Code you'll get code completion and documentation as you author thehypar.json
. - Use the CLI to generate input and output classes and a function stub. From the same directory as your
hypar.json
do:hypar init
. This will generateInput.gs.cs
andOutput.g.cs
classes which have properties which match your input and output properties. Addtionally, it will generate a<function-id>.g.cs
whoseExecute(...)
method is where you put your business logic. - Build
dotnet build
- Use the Hypar CLI to publish your function.
cd <function directory>
hypar publish
- Preview
.glb
models generated by Hypar locally using the glTF Extension for Visual Studio Code, or Don McCurdy's online glTF Viewer.
cd test
dotnet test