hypar-io / elements Goto Github PK
View Code? Open in Web Editor NEWThe smallest useful BIM.
Home Page: https://www.hypar.io
License: MIT License
The smallest useful BIM.
Home Page: https://www.hypar.io
License: MIT License
The Elements library should have types which represent mechanical systems and equipment according to @wynged.
// A component in a directed mechanical system.
public interface IConnection
{
// The input port.
Port In{get;}
// The output ports.
Port[] Out{get;}
}
// A mechanical Duct.
// The ICurveProvider interface requires an ICurve representing the center line of the Element.
// The IProfileProvider interface requires a Profile representing the cross-section shape of the element.
public class Duct : IElement, IConnection, ICurveProvider, IProfileProvider{...}
// An electrical conduit.
public class Conduit : IElement, IConnection, ICurveProvider, IProfileProvider{...}
// A piece of mechanical equipment which will be represented
// by a box with the given dimensions and have Ports
public interface IEquipment : IConnection
{
double Width{get;}
double Length{get;}
double Height{get;}
}
public class VAV : IElement, IEquipment{...}
public class Fan : IElement, IEquipment{...}
public class Diffuser : IElement, IEquipment{...}
public class Fitting : IElement, IEquipment{...}
Create a number of operations on a transform:
var t = new Transform();
t.Scale = new Vector();
t.Rotation = 42.0;
t.Translation = new Vector();
If these don't get us the user experience that we want, we'll do these:
The idea of creating a .net project, having to change directories into that project, then building the project, is a workflow that is foreign to some of our early adopters. For these early adopters, the whole project setup and build pipeline is currently handled by Visual Studio.
The CLI doesn't have to do as much work in hypar new
. Currently, there is bootstrapping code in the new command which creates a project and a default class file. This can be replaced with a github repository that has everything a starter project needs. We didn't do this initially for fear that having github as a dependency would be a stumbling block. But it seems that some early adopters are more comfortable using github (most likely through the GUI) than they are using the command line.
The workflow would therefore look like this:
git clone https://github.com/hypar-io/dotnet-starter
or git clone https://github.com/hypar-io/python-starter
.For dotnet, the starter project could also have the Hypar CLI as a build tool, so we wouldn't have to distribute the CLI using a zip.
Currently the user has to edit the hypar.json file to associate input parameters with their handler. Although having a json configuration file at the root of your project directory is now common practice for many frameworks (npm, dotnet, etc.), the association was unclear to our early adopters.
There are a few possible solutions:
public class FooInput
{
[Description("The length of the thing.")]
[Range(0, 10)]
public double Length{get;set;}
[Description("The height of the thing.")]
[Range(0, 10)]
public double Height{get;set;}
[Description("The width of the thing.")]
[Range(0, 10)]
public double Width{get;set;}
}
Reflection to generate the hypar.json would happen during publish.
The update Panel
type creates a lamina solid which has two faces. These two faces cause self-shadowing artifacts when visualized from the glTF in threejs.
glTF supports the LINE
primitive. Supporting lines would enable us to write centerlines, profiles, and dimensions to the assets.
glTF content generator info on lines.
Issue about adding lines example to glTF.
See the outlined box example.
The Hypar VS Code extension would allow the user to publish from VS Code. An example of an extension is located here:
https://code.visualstudio.com/docs/extensions/example-hello-world
Serializing and deserializing model from JSON text seems to have issues. I've created this test in using they hypar generator, but I believe the error lies in the Model.cs class and how it loads from JSON, so I've put the issue here. A mystery new 'black' material gets created on load, which causes errors when the materials are turned into a dictionary later. To do my tests I've had to remove this extra material from the materials after a model is loaded.
To recreate:
hypar new
hypar init src
and return a valid output from your test functions execute method.return new Output(input.Model, 1.0);
System.IO.File.WriteAllText("../../../model.json", output["elements"].ToString());
var modeljson = System.IO.File.ReadAllText("../../../model.json");
var mdl = Model.FromJson(modeljson);
Console.WriteLine(string.Join("\n", mdl.Materials.Select(m=>$"{m.Key}: {m.Value.Name}")));
_data.Model = mdl;
mdl
variable, you should see that it has 3 materials. there are two materials with familiar GUIDs from the model.json, but there is an additional material, new GUID, also called 'black'This will cause the execution to fail at a later step, but it is this moment where there are 3 materials in a model loaded from a json with only 2 materials that I believe the error is introduced.
Add a Travis integration and README badge.
Unhandled Exception: Newtonsoft.Json.JsonSerializationException: Could not create an instance of type Hypar.Configuration.ParameterData. Type is an interface or abstract class and cannot be instantiated. Path 'parameters.height.min', line 9, position 18.
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewObject(JsonReader reader, JsonObjectContract objectContract, JsonProperty containerMember, JsonProperty containerProperty, String id, Boolean& createdFromNonDefaultCreator)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateDictionary(IDictionary dictionary, JsonReader reader, JsonDictionaryContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
at Hypar.Commands.NewCommand.UpdateHyparJson(String directory, String name) in /Users/ikeough/Documents/hypar/sdk/csharp/src/cli/Commands/NewCommand.cs:line 77
at Hypar.Commands.NewCommand.New(String functionName) in /Users/ikeough/Documents/hypar/sdk/csharp/src/cli/Commands/NewCommand.cs:line 53
at Hypar.Program.Main(String[] args) in /Users/ikeough/Documents/hypar/sdk/csharp/src/cli/Program.cs:line 65
If a new element is added to a hypar model and given a new type (ex. "VAV"), then converted into a JSON, an issue occurs when you attempt to deserialize it. This error occurs.
It's likely coming from here, where its referencing the list of acceptable element types. "VAV" may not be in the acceptable list and therefore throws the error.
@wynged has also been digging into it.
Re: https://github.com/hypar-io/sdk/blob/master/src/sdk/Elements/Element.cs#L61
I'm not sure if this has come up in the documentation, and so apologies if I missed a rationale somewhere -- and I haven't actually bumped into this as a problem yet, so this issue might be well suited to be closed wontfix-yagni.
Have you considered allowing elements to have deterministically generated ids? There are a number of workflows that could grow around hypar functions that depend on attaching information to elements, even though the extra data does not originate inside the hypar function itself.
For example, say I have a viewer that allows me to change the visibility of individual items, so that I can eg closely inspect the anchors for curtainwall panels. As I tweak and regenerate the model with randomly generated ids, either the viewer has to reset state with each iteration, or do a lot of work to guess which elements "match" between iterations. Some sort of determinism in id assignment could help with this and similar workflows.
Move these settings out and add them to the .gitignore.
In Model.ToHypar()
, return an the elements
collection with the key elements
.
Now that Polygon
and Polyline
are planar, we need to adjust sets of points returned from Grid
to be of type IEnumerable<Vector3>
.
The constructor should now be:
public Grid(IEnumerable<Vector3> corners, int uDivisions = 1, int vDivisions = 1){...}
"sdk" is a little ambiguous. It would probably be helpful to developers if we branded it.
Some of this I'll pull directly from the Shapely functionality set: https://toblerity.org/shapely/manual.html
Polygon Properties
Area (For closed shapes. Polygon? BBox?)
Bounding box for planar geometry (I realize the user can construct a BBox. If you want to leave this as is, I'm okay with it, but the libraries I've look at all seem to provide this information as a property of the geometric entity)
Center - Returns the center of the BBox. Not strictly necessary, occasionally convenient.
Centroid
Length (in Polygon land, this is equal to the linear circumference).
PointWithin - Returns a cheaply computed point that is guaranteed to be within the geometric object. We could relegate this somewhere else as a method that can be performed on a Polygon.
Geometric Comparisons
To keep this simple, I thought these comparisons could happen as if all 2D geometries shared a plane. If you think these should respect z-axis separation, so that Polygons that would return "True" to an overlap test would instead return "False" if they differ in z-axis comparison, just let me know. I'm okay either way, we would just want our implementation to be consistent in this regard.
This is isn't really a design, just a summary of desired functionality. (I realize things like "IsContaining" could just be called "Contains" but I was imagining a consistent convention for comparisons. I'm okay either way.)
Shapely thinks about Polygons as having 3 distinct concepts...
...and several of these defintions assume that distinction.
Geometric Operations
Except in the first case, I don't know if you want to construct a new one or create a transform for the existing Geometry.
Elements
Installing the Hypar CLI as a NuGet command line tool will allow us to use NuGet for distribution. We can reference the Hypar CLI package in the starter repo and have the package synced to the solution. Then we can call dotnet hypar-cli.dll publish
during dotnet publish
to have the function pushed to Hypar automatically.
Port the colors in AECDataTypes
to new static constructors on the Color
class like:
public static Color Red(){...}
public static Color Blue(){...}
...
A Polygon
is closed, planar, n-sided geometry.
IEnumerable<Polygon>
would make sense.// A topographic mesh derived from a field of Vector3.
public class Topography : IElement, IGeometry3D
{
public Topography(Vector3[][] points){ ... }
// Get all subsets of this topography where the slope angle is
public Topography[] AreasWithSlopeGreaterThan(double slope){ ... }
public Topography[] AreasWithSlopeLessThan(double slope){ ... }
public Topography[] AreasWithSlopeEqualTo(double slope){ ... }
public void Tesselate(ref Mesh mesh){ ... }
}
A Space is a volume created by extruding a set of co-planar polygons to a height, or by projecting a a set of co-planar polygons onto a plane. The first polygon provided in the set is understood to be the outer boundary of the space, with the ensuing polygons understood to be ordered in an CW direction representing "holes" in the space.
public Space(Polygon boundary, IEnumerable<Polygon> voids, double height){...}
public Space(Polygon boundary, IEnumerable<Polygon> voids, Plane plane){...}
Elements should be able to query information out of an IFC file. Although full coverage of IFC is a long way off, Elements should at least understand the types for which a mapping makes sense (i.e. Walls, Floors, Spaces, Structural).
Hypar.IFC
.Elements
namespace out of IFC-dotnet into Hypar.IFC
Model.FromIFC(string ifcPath)
BaseIfc
instances to Element
instances.Lambda has a fixed return size of 6mb of JSON. With geometry now being serialized to JSON, the JSON is too large to return uncompressed in many cases. It may be that compressing it will handle most cases, but the geometry is not necessary to be encoded in the JSON all the time. We can generate "one-way" JSON for the element data.
I've attempted the following to reproduce:
hypar publish
to get a login prompt.
Thinking that perhaps there was some AWS configuration stuff that was still being used by the login process, I removed my aws credentials file altogether, and retried the steps above with another test user. And it succeeded.
Verified that this fails the same way using the Linux and Windows CLIs.
public bool AreCoplanar(this IEnumerable<Vector3> points){...}
public Polygon Thicken(double thickness)
Currently the CLI generates a dotnet C# project. The CLI should also give the option to create a python function. Because we want to share the Hypar SDK between the two, we are considering using the Hypar SDK via Iron Python. We must determine the following:
This will need to use Iron Python 2.7.8.
The example link in the readme is referring to the old link here. The new link appears to be https://github.com/hypar-io/elements/tree/master/csharp/test Just wanted to give you guys a heads up. 😉
Early adopters identified that the project generated by the Hypar CLI cannot be built right away when you open its folder in Visual Studio Code. This is because the generated project doesn't contain a C# build or test configuration. This should be included in the starter projects referenced in #24.
Trying to create a function with the name test_Function_WoW
results in an inability to create an S3 bucket. Most likely this is due to the limitation of S3 bucket names and _
. The name should be cleaned to be test_function_wow
.
As a developer, I should be able to split a Solid
created with the elements library.
Solid[] Split(Plane p)
public Floor(Polygon boundary, IEnumerable<Polygon> voids, double thickness, double elevation){...}
Feature
array as provided by MapBox.
Geometry
types.Polyline
, using the first position as the origin.Early adopters identified that the projects generated by hypar new
don't have an obvious way to test the results. The starter projects referenced in #24 should include test projects that are bootstrapped to run the function with test data.
.sln
file should reference both the function project and the test project. hypar publish
should only publish the function project.dotnet test
.python -m unittest
.A model with no elements should make a valid empty glb or no glb at all. In the latter case, an exception should be thrown that indicates clearly that there’s no elements in the model.
{
"errorType": "ArgumentOutOfRangeException",
"errorMessage": "Expected value to be greater than or equal to 1\nParameter name: ByteLength\nActual value was 0.",
"stackTrace": [
"at glTFLoader.Schema.Buffer.set_ByteLength(Int32 value)",
"at Hypar.Elements.Model.InitializeGlTF()",
"at Hypar.Elements.Model.SaveBase64()",
"at Hypar.Elements.Model.ToHypar()",
"at lambda_method(Closure , Stream , Stream , LambdaContextInternal )"
]
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.