Skip to content

Instantly share code, notes, and snippets.

@andrewheumann
Last active November 15, 2020 19:41
Show Gist options
  • Save andrewheumann/f3c47f74047567f6edf9661f795aa3ab to your computer and use it in GitHub Desktop.
Save andrewheumann/f3c47f74047567f6edf9661f795aa3ab to your computer and use it in GitHub Desktop.
Sample Hypar Function - Complete
using Elements;
using Elements.Geometry;
using System.Collections.Generic;
namespace StarterFunction
{
public static class StarterFunction
{
/// <summary>
/// My very first hypar function
/// </summary>
/// <param name="model">The input model.</param>
/// <param name="input">The arguments to the execution.</param>
/// <returns>A StarterFunctionOutputs instance containing computed results and the model with any new elements.</returns>
public static StarterFunctionOutputs Execute(Dictionary<string, Model> inputModels, StarterFunctionInputs input)
{
// create an output object
var output = new StarterFunctionOutputs(input.Width * input.Length * input.Height, input.Width * input.Length);
// create a rectangle
var rectangle = Polygon.Rectangle(input.Width, input.Length);
// create an inner void rectangle
var innerRectangle = Polygon.Rectangle(input.Width * 0.5, input.Length * 0.5);
// create a profile from the two rectangles
var profile = new Profile(rectangle, innerRectangle);
// create a new material
var material = new Material("Box Color", input.MassColor);
// create a mass from the rectangle
var mass = new Mass(profile, input.Height, material);
// add the mass to the output model
output.Model.AddElement(mass);
return output;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment