Skip to content

Commit

Permalink
update SpaceConfigFromModel for building
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonie-kramer committed Jan 5, 2024
1 parent 4a75697 commit 3f49638
Show file tree
Hide file tree
Showing 5 changed files with 169 additions and 2 deletions.
12 changes: 12 additions & 0 deletions SpaceConfigurationFromModel/dependencies/ProgramRequirement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using Newtonsoft.Json;

namespace Elements
{
public partial class ProgramRequirement : IProgramRequirement
{
[JsonProperty("Qualified Program Name")]
public string QualifiedProgramName => String.IsNullOrWhiteSpace(this.ProgramGroup) ? this.ProgramName : $"{this.ProgramGroup} - {this.ProgramName}";
public int CountPlaced { get; set; }
}
}
116 changes: 116 additions & 0 deletions SpaceConfigurationFromModel/dependencies/ProgramRequirement.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
//----------------------
// <auto-generated>
// Generated using the NJsonSchema v10.1.21.0 (Newtonsoft.Json v13.0.0.0) (http://NJsonSchema.org)
// </auto-generated>
//----------------------
using Elements;
using Elements.GeoJSON;
using Elements.Geometry;
using Elements.Geometry.Solids;
using Elements.Spatial;
using Elements.Validators;
using Elements.Serialization.JSON;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using Line = Elements.Geometry.Line;
using Polygon = Elements.Geometry.Polygon;

namespace Elements
{
#pragma warning disable // Disable all warnings

/// <summary>Fill out your program requirements. Use "Hypar Space Type" to dictate which function should be used to lay out your space.</summary>
[JsonConverter(typeof(Elements.Serialization.JSON.JsonInheritanceConverter), "discriminator")]
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.21.0 (Newtonsoft.Json v13.0.0.0)")]
public partial class ProgramRequirement : Element
{
[JsonConstructor]
public ProgramRequirement(string @programGroup, string @programName, Color? @color, double @areaPerSpace, int @spaceCount, double? @width, double? @depth, string @hyparSpaceType, ProgramRequirementCountType @countType, double @totalArea, System.Guid? @spaceConfig, System.Guid? @layoutTypeId, System.Guid? @catalog, System.Guid @id = default, string @name = null)
: base(id, name)
{
this.ProgramGroup = @programGroup;
this.ProgramName = @programName;
this.Color = @color;
this.AreaPerSpace = @areaPerSpace;
this.SpaceCount = @spaceCount;
this.Width = @width;
this.Depth = @depth;
this.HyparSpaceType = @hyparSpaceType;
this.CountType = @countType;
this.TotalArea = @totalArea;
this.SpaceConfig = @spaceConfig;
this.LayoutTypeId = @layoutTypeId;
this.Catalog = @catalog;
}


// Empty constructor
public ProgramRequirement()
: base()
{
}

/// <summary>What group does this program belong to?</summary>
[JsonProperty("Program Group", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string ProgramGroup { get; set; }

/// <summary>What display name should be used for this program type?</summary>
[JsonProperty("Program Name", Required = Newtonsoft.Json.Required.Always)]
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
public string ProgramName { get; set; }

/// <summary>What color should be used to display this space type?</summary>
[JsonProperty("Color", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public Color? Color { get; set; }

/// <summary>How much area should be allocated for this space?</summary>
[JsonProperty("Area per Space", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public double AreaPerSpace { get; set; }

/// <summary>How many of this space type are required? Leave at 1 for spaces measured in aggregate, like circulation.</summary>
[JsonProperty("Space Count", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public int SpaceCount { get; set; } = 1;

/// <summary>Optional. (Typically the longer dimension — along the side from which the space is accessed, like a corridor.)</summary>
[JsonProperty("Width", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public double? Width { get; set; }

/// <summary>Optional. (Typically the shorter dimension — perpendicular to the side from which the space is accessed, like a corridor.)</summary>
[JsonProperty("Depth", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public double? Depth { get; set; }

/// <summary>Which furniture layout function should be used to lay out this space?</summary>
[JsonProperty("Hypar Space Type", Required = Newtonsoft.Json.Required.Always)]
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
public string HyparSpaceType { get; set; } = "unspecified";

/// <summary>How should this requirement be counted?
///
/// Use "Item" for individual spaces (e.g. 3 conference rooms),
/// "Area Total" for spaces where you only care about the total (e.g. 1000 SF of circulation), and
/// "Unit" where you want total area divided by a "unit" size (e.g. this space supports 400 people at 120 SF / person)</summary>
[JsonProperty("Count Type", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
public ProgramRequirementCountType CountType { get; set; } = Elements.ProgramRequirementCountType.Item;

/// <summary>The Area per Space times the Space Count</summary>
[JsonProperty("Total Area", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public double TotalArea { get; set; }

/// <summary>The guid of the space configuration</summary>
[JsonProperty("SpaceConfig", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public System.Guid? SpaceConfig { get; set; }

/// <summary>The guid of the layout type</summary>
[JsonProperty("Layout Type Id", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public System.Guid? LayoutTypeId { get; set; }

/// <summary>The guid of the catalog</summary>
[JsonProperty("Catalog", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public System.Guid? Catalog { get; set; }


}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//----------------------
// <auto-generated>
// Generated using the NJsonSchema v10.1.21.0 (Newtonsoft.Json v13.0.0.0) (http://NJsonSchema.org)
// </auto-generated>
//----------------------
using Elements;
using Elements.GeoJSON;
using Elements.Geometry;
using Elements.Geometry.Solids;
using Elements.Spatial;
using Elements.Validators;
using Elements.Serialization.JSON;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using Line = Elements.Geometry.Line;
using Polygon = Elements.Geometry.Polygon;

namespace Elements
{
#pragma warning disable // Disable all warnings

[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.21.0 (Newtonsoft.Json v13.0.0.0)")]
public enum ProgramRequirementCountType
{
[System.Runtime.Serialization.EnumMember(Value = @"Item")]
Item = 0,

[System.Runtime.Serialization.EnumMember(Value = @"Area Total")]
Area_Total = 1,

}
}
3 changes: 2 additions & 1 deletion SpaceConfigurationFromModel/hypar.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
"https://schemas.hypar.io/LevelElements.json",
"https://schemas.hypar.io/CirculationSegment.json",
"https://schemas.hypar.io/LevelVolume.json",
"https://schemas.hypar.io/ServiceCore.json"
"https://schemas.hypar.io/ServiceCore.json",
"https://schemas.hypar.io/ProgramRequirement.json"
],
"repository_url": "https://github.com/hypar-io/function",
"last_updated": "0001-01-01T00:00:00",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ public static SpaceConfigurationFromModelOutputs Execute(Dictionary<string, Mode

var programName = input.Program ?? "Open Office";
var layoutGeneration = new SpaceConfigurationFromModelLayoutGeneration(spaceConfiguration);
var result = layoutGeneration.StandardLayoutOnAllLevels(programName, inputModels, null, false, null, input.ModelFile.LocalFilePath);

string configJsonPath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), input.ModelFile.LocalFilePath);
SpaceConfiguration configs = ContentManagement.GetSpaceConfiguration<ProgramRequirement>(inputModels, configJsonPath, programName);

var result = layoutGeneration.StandardLayoutOnAllLevels(programName, inputModels, null, false, configs);
output.Model = result.OutputModel;
return output;
}
Expand Down

0 comments on commit 3f49638

Please sign in to comment.