Example #1
0
        public async void Joists()
        {
            Name = nameof(Joists);

            // <joist-example>
            var xSpacing = 10.0;
            var yLength  = 30;

            var profileFactory = new LProfileFactory();
            var profile8       = await profileFactory.GetProfileByTypeAsync(LProfileType.L8X8X5_8);

            var profile2 = await profileFactory.GetProfileByTypeAsync(LProfileType.L2X2X1_8);

            var profile5 = await profileFactory.GetProfileByTypeAsync(LProfileType.L5X5X1_2);

            var line  = new Line(new Vector3(0, 0, 0), new Vector3(0, yLength, 0));
            var joist = new Joist(line,
                                  profile8,
                                  profile8,
                                  profile2,
                                  Units.InchesToMeters(48),
                                  20,
                                  Units.InchesToMeters(2.5),
                                  Units.FeetToMeters(2.0),
                                  BuiltInMaterials.Steel)
            {
                IsElementDefinition = true
            };


            var cl         = new Line(new Vector3(0, 0, 0), new Vector3(xSpacing, 0, 0));
            var firstJoist = new Joist(cl,
                                       profile5,
                                       profile5,
                                       profile2,
                                       Units.InchesToMeters(24),
                                       10,
                                       Units.InchesToMeters(2.5),
                                       Units.FeetToMeters(1),
                                       BuiltInMaterials.Steel)
            {
                IsElementDefinition = true
            };

            for (var x = 0.0; x < 100.0; x += xSpacing)
            {
                var t             = new Transform(new Vector3(x, 0, 4));
                var joistInstance = joist.CreateInstance(t, $"joist_girder_{x}");
                Model.AddElement(joistInstance);

                var joistPoints = joist.JoistPoints.Select(jp => t.OfPoint(jp)).ToList();
                for (var i = 0; i < joistPoints.Count; i++)
                {
                    var pt = joistPoints[i];
                    var innerJoistInstance = firstJoist.CreateInstance(new Transform(pt), $"joist_{x}_{i}");
                    Model.AddElement(innerJoistInstance);
                }
            }
            // <joist-example>
        }
Example #2
0
        /// <summary>
        /// The PrefabricatedPanels function.
        /// </summary>
        /// <param name="model">The input model.</param>
        /// <param name="input">The arguments to the execution.</param>
        /// <returns>A PrefabricatedPanelsOutputs instance containing computed results and the model with any new elements.</returns>
        public static PrefabricatedPanelsOutputs Execute(Dictionary <string, Model> inputModels, PrefabricatedPanelsInputs input)
        {
            var wallPanels = inputModels["WallPanels"].AllElementsOfType <WallPanel>();

            var panelCount         = 0;
            var totalFramingLength = 0.0;
            var elements           = new List <Element>();

            var studWidth         = Elements.Units.InchesToMeters(3.625);
            var studDepth         = Elements.Units.InchesToMeters(1.5);
            var tolerance         = 0.005;
            var studProfile       = new StudProfile();
            var outerStudMaterial = new Material("Stud Frame", Colors.Orange);
            var studMaterial      = new Material("Stud", new Color(0.7, 0.7, 0.7, 1.0), 0.8f, 0.8f);
            var headerProfile     = new Profile(Polygon.Rectangle(Units.InchesToMeters(3.625), Units.InchesToMeters(3.625)));
            var headerTrans       = new Transform(new Vector3(0, Units.InchesToMeters(3.625) / 2));
            // headerProfile.Transform(headerTrans);

            var centerLineMaterial = new Material("Center Line", Colors.Gray);
            var wallBoard          = new Material("Wall Board", new Color(0.9, 0.9, 0.9, 0.75), 0.0f, 0.0f);

            foreach (var panel in wallPanels)
            {
                // Draw the panel profiles.
                // var mc = new ModelCurve(panel.Transform.OfPolygon(panel.Profile.Perimeter), centerLineMaterial);
                // elements.Add(mc);

                var wallBoardOffset = panel.Profile.Perimeter.Offset(-tolerance);

                // Offset the panel profile
                var offset = panel.Profile.Perimeter.Offset(-studDepth / 2 - tolerance);
                if (offset.Length == 0)
                {
                    continue;
                }
                var outer = (Polygon)offset[0].Transformed(panel.Transform);

                // Get the plane of the panel
                var panelPlane = outer.Plane();

                // Draw the panel transform;
                // var panelTransform = new Transform(outer.Centroid(), panelPlane.Normal);
                // elements.AddRange(panelTransform.ToModelCurves());

                // Draw the panel frame.

                foreach (var seg in outer.Segments())
                {
                    var l   = seg.Length();
                    var d   = seg.Direction();
                    var dot = d.Dot(Vector3.ZAxis);
                    var t   = seg.TransformAt(0);

                    // Draw the beam transforms
                    // elements.AddRange(t.ToModelCurves());

                    var beamRotation = t.XAxis.AngleTo(panelPlane.Normal);
                    // if(Double.IsNaN(beamRotation))
                    // {
                    //  Console.WriteLine($"l: {l}, d:{d}, dot:{dot}");
                    // }

                    Vector3 a, b;
                    if (Math.Abs(dot) == 1)
                    {
                        a = seg.Start += d * studDepth / 2;
                        b = seg.End -= d * studDepth / 2;
                    }
                    else
                    {
                        a = seg.Start -= d * studDepth / 2;
                        b = seg.End += d * studDepth / 2;
                    }

                    var cl = new Line(a, b);
                    // var beam = new Beam(cl, (dot == 0.0 && seg.Start.Z > 0.1) ? headerProfile : studProfile, outerStudMaterial, rotation: (Double.IsNaN(beamRotation) ? 0.0 : beamRotation));
                    var beam = new Beam(cl, studProfile, outerStudMaterial, rotation: (Double.IsNaN(beamRotation) ? 0.0 : beamRotation));
                    totalFramingLength += cl.Length();

                    elements.Add(beam);
                }

                // Draw the panel framing.

                var grid = new Grid2d(offset[0]);
                grid.U.DivideByFixedLength(input.StudSpacing);

                var studCls = grid.GetCellSeparators(GridDirection.V);

                // Only take the inner studs.
                var innerCls        = studCls.Skip(1).Take(studCls.Count - 2).ToList().Cast <Line>().ToList();
                var trimBoundary    = offset[0].Segments();
                var trimmedInnerCls = TrimLinesToBoundary(innerCls, trimBoundary);

                foreach (var trimmedLine in trimmedInnerCls)
                {
                    var t            = trimmedLine.TransformAt(0);
                    var beamRotation = t.XAxis.AngleTo(panelPlane.Normal);
                    var innerBeam    = new Beam(trimmedLine.Transformed(panel.Transform), studProfile, studMaterial, rotation: beamRotation);
                    totalFramingLength += trimmedLine.Length();
                    elements.Add(innerBeam);
                }

                grid.V.DivideByFixedLength(Units.FeetToMeters(4.0));
                var kickerCls        = grid.GetCellSeparators(GridDirection.U);
                var kickerInnerCls   = kickerCls.Skip(1).Take(kickerCls.Count - 2).ToList().Cast <Line>().ToList();;
                var trimmedKickerCls = TrimLinesToBoundary(kickerInnerCls, trimBoundary);
                foreach (var trimmedKicker in trimmedKickerCls)
                {
                    var beam = new Beam(trimmedKicker.Transformed(panel.Transform), studProfile, studMaterial);
                    totalFramingLength += trimmedKicker.Length();
                    elements.Add(beam);
                }

                if (input.CreateWallBoard)
                {
                    var wallBoardGrid = new Grid2d(wallBoardOffset[0]);
                    wallBoardGrid.U.DivideByFixedLength(Units.FeetToMeters(8.0));
                    wallBoardGrid.V.DivideByFixedLength(Units.FeetToMeters(4.0));

                    if (wallBoardGrid.CellsFlat.Count > 0)
                    {
                        foreach (var cell in wallBoardGrid.CellsFlat)
                        {
                            foreach (Polygon panelPerimeter in cell.GetTrimmedCellGeometry())
                            {
                                var wallBoards = CreateOffsetPanel(panel, studWidth, panelPerimeter, wallBoard);
                                elements.AddRange(new[] { wallBoards.left, wallBoards.right });
                            }
                        }
                    }
                    else
                    {
                        var panelPerimeter = wallBoardOffset[0];
                        var wallBoards     = CreateOffsetPanel(panel, studWidth, panelPerimeter, wallBoard);
                        elements.AddRange(new[] { wallBoards.left, wallBoards.right });
                    }
                }

                panelCount++;
            }

            var output = new PrefabricatedPanelsOutputs(panelCount, totalFramingLength);

            output.Model.AddElements(elements);
            return(output);
        }
        private static List <SolidAnalysisObject> getEastMidtownEnvelopes(List <Envelope> envelopes, List <RhinoBrep> rhinoBreps, List <RhinoExtrusion> rhinoExtrusions, List <MeshElement> meshEnvelopes, Model model, Boolean showDebugGeometry)
        {
            var analysisObjects = new List <SolidAnalysisObject>();

            var up                      = new Vector3(0, 0, 1);
            var cutHeight               = Units.FeetToMeters(150.0);
            var plane                   = new Plane(new Vector3(0, 0, cutHeight), Vector3.ZAxis);
            var envelopesForBlockage    = new List <Envelope>();
            var meshElementsForBlockage = new List <MeshElement>();

            foreach (var envelope in envelopes)
            {
                var bottom = envelope.Elevation;
                var top    = bottom + envelope.Height;

                if (top < cutHeight)
                {
                    continue;
                }

                if (bottom >= cutHeight)
                {
                    // envelope is above the cutoff, use as-is
                    analysisObjects.AddRange(SolidAnalysisObject.MakeFromEnvelopes(new List <Envelope>()
                    {
                        envelope
                    }));
                }
                else
                {
                    envelopesForBlockage.AddRange(GeoUtilities.SliceAtHeight(envelope, cutHeight, showDebugGeometry));
                }
            }

            foreach (var rhinoBrep in rhinoBreps)
            {
                envelopesForBlockage.AddRange(GeoUtilities.SliceAtHeight(rhinoBrep, cutHeight, showDebugGeometry));
            }

            foreach (var rhinoExtrusion in rhinoExtrusions)
            {
                envelopesForBlockage.AddRange(GeoUtilities.SliceAtHeight(rhinoExtrusion, cutHeight, showDebugGeometry));
            }

            foreach (var meshElement in meshEnvelopes)
            {
                var bbox   = new BBox3(GeoUtilities.TransformedVertices(meshElement.Mesh.Vertices, meshElement.Transform));
                var bottom = bbox.Min.Z;
                var top    = bbox.Max.Z;

                if (top < cutHeight)
                {
                    continue;
                }

                if (bottom >= cutHeight)
                {
                    // envelope is above the cutoff, use as-is
                    meshElementsForBlockage.Add(meshElement);
                }
                else
                {
                    envelopesForBlockage.AddRange(GeoUtilities.SliceAtHeight(meshElement, cutHeight, showDebugGeometry));
                }
            }

            analysisObjects.AddRange(SolidAnalysisObject.MakeFromEnvelopes(envelopesForBlockage));
            analysisObjects.AddRange(SolidAnalysisObject.MakeFromMeshElements(meshElementsForBlockage));

            return(analysisObjects);
        }
        private static void calculateDaylightBoundaries(NYCDaylightEvaluationVantageStreet vantageStreet, List <VantagePoint> orderedStreetVantagePts, Model model = null)
        {
            Console.WriteLine("Calculate Daylight Boundaries");

            if (orderedStreetVantagePts.Count < 2 || orderedStreetVantagePts.Count > 3)
            {
                throw new Exception($"Vantage streets must have a minimum of two and a maximum of three vantage points. {orderedStreetVantagePts.Count} vantage points were found.");
            }

            foreach (var vp in orderedStreetVantagePts.Take(2))
            {
                var farPoint = vp.Point + (vp.StartDirection * VantageDistance) + (vp.FrontDirection * vantageStreet.CenterlineDistance);
                vp.DaylightBoundariesPoints[0] = farPoint;
            }

            if (orderedStreetVantagePts.Count == 2)
            {
                foreach (var vp in orderedStreetVantagePts)
                {
                    var nearPointOnNearLot = new List <Vector3>()
                    {
                        vp.NearLotLine.Start, vp.NearLotLine.End
                    }.OrderBy(pt => pt.DistanceTo(vp.Point)).ToList()[0];
                    var frontageLength = vp.VantageStreet.FrontLotLine.Length();
                    if (frontageLength > VantageDistance)
                    {
                        // 81-275 Special Conditions a.1: length of street frontage > 250ft and < 500ft
                        // If > 500ft, we would've had 3 vantage points so we wouldn't have reached this point.
                        vp.DaylightBoundariesPoints[1] = nearPointOnNearLot;
                    }
                    else
                    {
                        // 81-273f:
                        // Draw a vertical line on the chart rising from the intersection of the near lot line of the zoning lot
                        // with the center line of the block or with a line 100 feet distant from and parallel to the front lot line on the vantage street,
                        // whichever line is closer to the vantage street.
                        // This line and the far lot line represent the boundaries of the potential sky area that the building could block.

                        // Move intersection point of the near lot line and front lot line
                        // towards the rear, to the lesser of 100' or the outputVantageStreet.Centerline of the block from the front lot line
                        var pointForBounds = nearPointOnNearLot + vp.FrontDirection * Math.Min(Units.FeetToMeters(100), vp.VantageStreet.BlockDepth / 2);
                        vp.DaylightBoundariesPoints[1] = pointForBounds;
                    }
                }
            }

            if (orderedStreetVantagePts.Count == 3)
            {
                foreach (var vp in orderedStreetVantagePts.SkipLast(1))
                {
                    vp.DaylightBoundariesPoints[1] = vp.Point + (vp.FrontDirection * vp.VantageStreet.CenterlineDistance);
                }
                var vp1 = orderedStreetVantagePts[0];
                var vp2 = orderedStreetVantagePts[1];
                var vp3 = orderedStreetVantagePts[2];
                vp3.DaylightBoundariesPoints[0] = vp1.DaylightBoundariesPoints[1];
                vp3.DaylightBoundariesPoints[1] = vp2.DaylightBoundariesPoints[1];
            }

            foreach (var vp in orderedStreetVantagePts)
            {
                var min = vp.GetAnalysisPoint(vp.DaylightBoundariesPoints[0]).PlanAndSection.X;
                var max = vp.GetAnalysisPoint(vp.DaylightBoundariesPoints[1]).PlanAndSection.X;

                if (max < min)
                {
                    vp.DaylightBoundariesPoints.Reverse();
                    vp.DaylightBoundaries = new Domain1d(max, min);
                }
                else
                {
                    vp.DaylightBoundaries = new Domain1d(min, max);
                }
            }
        }
        /// <summary>
        /// Create an output vantage street from an input vantage street.
        /// </summary>
        public static NYCDaylightEvaluationVantageStreet CreateVantageStreet(Polygon rectangularSite, VantageStreets vantageStreet, out List <VantagePoint> vantagePoints, VantageStreetsOverride ovd = null, Model model = null)
        {
            if (vantageStreet.Line == null)
            {
                throw new Exception("Each vantage street must have a line designating its rough location. Please draw a line outside of your lot that represents the centerline of your vantage street. It does not need to be straight or exactly parallel to the lot line, but it must exist.");
            }
            var siteCentroid         = rectangularSite.Centroid();
            var midpoint             = vantageStreet.Line.PointAt(0.5);
            var lotLines             = new List <Line>(rectangularSite.Segments()).OrderBy(segment => midpoint.DistanceTo(segment.PointAt(0.5))).ToList();
            var originalFrontLotLine = lotLines[0];
            var frontLotLine         = ovd?.Value.FrontLotLine ?? originalFrontLotLine;
            var centerlineOffsetDist = Settings.CenterlineDistances[vantageStreet.Width] / 2;
            var directionToStreet    = new Vector3(originalFrontLotLine.PointAt(0.5) - siteCentroid).Unitized() * centerlineOffsetDist;
            var centerline           = new Line(frontLotLine.Start + directionToStreet, frontLotLine.End + directionToStreet);
            var outputVantageStreet  = new NYCDaylightEvaluationVantageStreet(0, centerlineOffsetDist, frontLotLine, centerline, vantageStreet.StreetWallContinuity, lotLines, Units.FeetToMeters(vantageStreet.BlockDepthInFeet), name: vantageStreet.Name);

            if (ovd != null)
            {
                outputVantageStreet.AddOverrideIdentity(ovd);
            }
            vantagePoints = VantagePoint.GetVantagePoints(outputVantageStreet, model);

            return(outputVantageStreet);
        }