Example #1
0
        public static Panel ToSAM(this gbXMLSerializer.Surface surface, double tolerance = Tolerance.MicroDistance)
        {
            if (surface == null)
            {
                return(null);
            }

            Polygon3D polygon3D = surface.PlanarGeometry.ToSAM(tolerance);

            if (polygon3D == null)
            {
                return(null);
            }

            PanelType panelType = Query.PanelType(surface.surfaceType);

            Construction construction = new Construction(surface.Name);

            Panel result = new Panel(construction, panelType, new Face3D(polygon3D));

            Opening[] openings = surface.Opening;
            if (openings != null)
            {
                foreach (Opening opening in openings)
                {
                    Aperture aperture = opening.ToSAM(tolerance);
                    if (aperture != null)
                    {
                        result.AddAperture(aperture);
                    }
                }
            }

            return(result);
        }
Example #2
0
        public static HoneybeeSchema.Door ToLadybugTools_Door(this Aperture aperture, MaterialLibrary materialLibrary = null, int index = -1, int index_Adjacent = -1, string adjacentPanelUniqueName = null, string adjacentSpaceUniqueName = null)
        {
            if (aperture == null)
            {
                return(null);
            }

            ApertureConstruction apertureConstruction = aperture.ApertureConstruction;

            if (apertureConstruction == null)
            {
                return(null);
            }

            MaterialType materialType = apertureConstruction.PaneConstructionLayers.MaterialType(materialLibrary);

            if (aperture.ApertureType != ApertureType.Door)
            {
                //Opaque Windows to be replaced by Doors
                if (materialType != MaterialType.Opaque)
                {
                    return(null);
                }
            }

            PlanarBoundary3D planarBoundary3D = aperture.PlanarBoundary3D;

            if (planarBoundary3D == null)
            {
                return(null);
            }

            HoneybeeSchema.AnyOf <Outdoors, Surface> anyOf = new Outdoors();

            Face3D face3D = planarBoundary3D.ToLadybugTools();

            if (!string.IsNullOrEmpty(adjacentPanelUniqueName) && !string.IsNullOrEmpty(adjacentSpaceUniqueName))
            {
                List <string> uniqueNames = new List <string>();
                uniqueNames.Add(Core.LadybugTools.Query.UniqueName(aperture, index_Adjacent));
                uniqueNames.Add(adjacentPanelUniqueName);
                uniqueNames.Add(adjacentSpaceUniqueName);

                anyOf = new Surface(uniqueNames);
            }

            DoorEnergyPropertiesAbridged apertureEnergyPropertiesAbridged = new DoorEnergyPropertiesAbridged(Query.UniqueName(apertureConstruction, !(index_Adjacent != -1 && index <= index_Adjacent)));

            HoneybeeSchema.Door door = new HoneybeeSchema.Door(
                identifier: Core.LadybugTools.Query.UniqueName(aperture, index),
                geometry: face3D,
                boundaryCondition: anyOf,
                properties: new DoorPropertiesAbridged(apertureEnergyPropertiesAbridged),
                displayName: aperture.Name);

            door.IsGlass = materialType == MaterialType.Transparent;
            return(door);
        }
        public void ToStringTest()
        {
            IsoSpeed isoSpeed = (IsoSpeed)IsoSpeed.IsoSpeeds.AtKey(IsoSpeedEnum.iso50);
            Aperture aperture = (Aperture)Aperture.Apertures.AtKey(ApertureEnum.f10);
            Exposal  exposal  = (Exposal)Exposal.Exposals.AtKey(ExposalEnum.t1_100);

            Assert.AreEqual("Iso 50, F10, 1/100", new ShootParameters(isoSpeed, aperture, exposal).ToString());
            Assert.AreEqual("Iso 50, F10, 1/100", new ShootParameters(isoSpeed, aperture, exposal).DisplayString);
        }
Example #4
0
        public static Log Log(this Aperture aperture)
        {
            if (aperture == null)
            {
                return(null);
            }

            return(Log((IIDdBase)aperture));
        }
Example #5
0
        public static HostObject HostObject(this Aperture aperture, Document document)
        {
            HostObject result = null;

            PanelGroup panelGroup = Analytical.Query.PanelGroup(Analytical.Query.PanelType(aperture.Plane.Normal));

            switch (panelGroup)
            {
            case PanelGroup.Wall:
                IEnumerable <Wall> walls = Geometry.Revit.Query.Elements <Wall>(document, aperture.GetBoundingBox());
                if (walls != null && walls.Count() != 0)
                {
                    result = walls.First();
                }
                break;

            case PanelGroup.Floor:
                IEnumerable <Element> elements_Floor = Geometry.Revit.Query.Elements(document, aperture.GetBoundingBox(), Autodesk.Revit.DB.BuiltInCategory.OST_Floors);
                if (elements_Floor != null && elements_Floor.Count() != 0)
                {
                    result = elements_Floor.First() as HostObject;
                }
                break;

            case PanelGroup.Roof:
                IEnumerable <Element> elements_Roof = Geometry.Revit.Query.Elements(document, aperture.GetBoundingBox(), Autodesk.Revit.DB.BuiltInCategory.OST_Roofs);
                if (elements_Roof != null && elements_Roof.Count() != 0)
                {
                    result = elements_Roof.First() as HostObject;
                }
                break;
            }

            if (result == null)
            {
                switch (panelGroup)
                {
                case PanelGroup.Roof:
                    IEnumerable <Element> elements_Floor = Geometry.Revit.Query.Elements(document, aperture.GetBoundingBox(), Autodesk.Revit.DB.BuiltInCategory.OST_Floors);
                    if (elements_Floor != null && elements_Floor.Count() != 0)
                    {
                        result = elements_Floor.First() as HostObject;
                    }
                    break;

                case PanelGroup.Floor:
                    IEnumerable <Element> elements_Roof = Geometry.Revit.Query.Elements(document, aperture.GetBoundingBox(), Autodesk.Revit.DB.BuiltInCategory.OST_Roofs);
                    if (elements_Roof != null && elements_Roof.Count() != 0)
                    {
                        result = elements_Roof.First() as HostObject;
                    }
                    break;
                }
            }

            return(result);
        }
        protected override void TrySolveInstance(IGH_DataAccess dataAccess)
        {
            int index = -1;
            int index_familyInstance = -1;

            index_familyInstance = Params.IndexOfOutputParam("familyInstance");
            if (index_familyInstance != -1)
            {
                dataAccess.SetData(index_familyInstance, null);
            }

            bool run = false;

            index = Params.IndexOfInputParam("_run");
            if (index == -1 || !dataAccess.GetData(index, ref run) || !run)
            {
                return;
            }

            ConvertSettings convertSettings = null;

            index = Params.IndexOfInputParam("_convertSettings_");
            if (index != -1)
            {
                dataAccess.GetData(index, ref convertSettings);
            }

            convertSettings = this.UpdateSolutionEndEventHandler(convertSettings);

            Aperture aperture = null;

            if (!dataAccess.GetData(0, ref aperture))
            {
                return;
            }

            Document document = RhinoInside.Revit.Revit.ActiveDBDocument;

            StartTransaction(document);

            Core.Revit.Modify.RemoveExisting(convertSettings, document, aperture);

            HostObject hostObject = Analytical.Revit.Query.HostObject(aperture, document);

            if (hostObject == null)
            {
                return;
            }

            FamilyInstance familyInstance_Revit = Analytical.Revit.Convert.ToRevit(aperture, document, hostObject, convertSettings);

            if (index_familyInstance != -1)
            {
                dataAccess.SetData(index_familyInstance, familyInstance_Revit);
            }
        }
Example #7
0
 public override void Calculate()
 {
     mark    = Block.GetPropValue <string>(propMark);
     length  = Block.GetPropValue <int>(propLength);
     height  = Block.GetPropValue <int>(propHeight);
     elev    = Block.GetPropValue <string>(propElevation);
     desc    = Block.GetPropValue <string>(propDesc, false);
     opening = GetAperture();
     AddElement(opening);
 }
Example #8
0
        public string Generate()
        {
            string gerber = "";

            gerber += Aperture.Generate();
            gerber += Interpolation.Linear;
            gerber += Start.Generate(Operation.Move);
            gerber += End.Generate(Operation.Draw);
            return(gerber);
        }
Example #9
0
        public static Aperture ToSAM(this HoneybeeSchema.Aperture aperture, bool @internal, IEnumerable <ApertureConstruction> apertureConstructions = null)
        {
            if (aperture == null)
            {
                return(null);
            }

            Geometry.Spatial.Face3D face3D = Geometry.LadybugTools.Convert.ToSAM(aperture.Geometry);
            if (face3D == null)
            {
                return(null);
            }

            ApertureConstruction apertureConstruction = null;

            if (apertureConstructions != null && aperture.Properties?.Energy?.Construction != null)
            {
                foreach (ApertureConstruction apertureConstruction_Temp in apertureConstructions)
                {
                    if (apertureConstruction_Temp == null)
                    {
                        continue;
                    }

                    if (apertureConstruction_Temp.ApertureType != ApertureType.Window)
                    {
                        continue;
                    }

                    if (aperture.Properties.Energy.Construction == apertureConstruction_Temp.Name)
                    {
                        apertureConstruction = apertureConstruction_Temp;
                        break;
                    }
                }
            }

            if (apertureConstruction == null)
            {
                AnyOf <OpaqueConstructionAbridged, WindowConstructionAbridged, ShadeConstruction, AirBoundaryConstructionAbridged> construction_Honeybee = Query.DefaultApertureConstruction(ApertureType.Window, @internal);
                if (construction_Honeybee != null)
                {
                    apertureConstruction = construction_Honeybee.ToSAM_ApertureConstruction();
                }
            }

            if (apertureConstruction == null)
            {
                apertureConstruction = new ApertureConstruction(aperture.DisplayName, ApertureType.Window);
            }

            Aperture result = new Aperture(apertureConstruction, face3D, Analytical.Query.OpeningLocation(face3D));

            return(result);
        }
Example #10
0
        public static Aperture ToSAM(this EnergyAnalysisOpening energyAnalysisOpening, ConvertSettings convertSettings)
        {
            if (energyAnalysisOpening == null)
            {
                return(null);
            }

            Aperture result = convertSettings?.GetObject <Aperture>(energyAnalysisOpening.Id);

            if (result != null)
            {
                return(result);
            }

            Polygon3D polygon3D = energyAnalysisOpening.GetPolyloop().ToSAM();

            if (polygon3D == null)
            {
                return(null);
            }

            FamilyInstance familyInstance = Core.Revit.Query.Element(energyAnalysisOpening) as FamilyInstance;

            if (familyInstance == null)
            {
                return(new Aperture(null, polygon3D));
            }

            if (Core.Revit.Query.Simplified(familyInstance))
            {
                result = Core.Revit.Query.IJSAMObjects <Aperture>(familyInstance)?.FirstOrDefault();
                if (result != null)
                {
                    return(result);
                }
            }

            ApertureConstruction apertureConstruction = ToSAM_ApertureConstruction(familyInstance, convertSettings);

            Point3D point3D_Location = Geometry.Revit.Query.LocationPoint3D(familyInstance);

            if (point3D_Location == null)
            {
                return(null);
            }

            result = new Aperture(apertureConstruction, polygon3D, point3D_Location);
            result.UpdateParameterSets(energyAnalysisOpening, ActiveSetting.Setting.GetValue <Core.TypeMap>(Core.Revit.ActiveSetting.Name.ParameterMap));
            //result.UpdateParameterSets(familyInstance, ActiveSetting.Setting.GetValue<Core.TypeMap>(Core.Revit.ActiveSetting.Name.ParameterMap));
            //result.Add(Core.Revit.Query.ParameterSet(familyInstance));

            convertSettings?.Add(energyAnalysisOpening.Id, result);

            return(result);
        }
Example #11
0
        public string Generate()
        {
            string gerber = "";

            gerber += Aperture.Generate();
            gerber += QuadrantMode.Multi;
            gerber += Interpolation.CircularClockwise;
            gerber += Start.Generate(Operation.Move);
            gerber += Draw(Start, End, Centre);
            return(gerber);
        }
Example #12
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Aperture.GetHashCode();
         hashCode = (hashCode * 397) ^ Gap.GetHashCode();
         hashCode = (hashCode * 397) ^ Annulus.GetHashCode();
         hashCode = (hashCode * 397) ^ (int)Type;
         return(hashCode);
     }
 }
Example #13
0
        public static Aperture Transform(this Transform transform, Aperture aperture)
        {
            if (transform == null || aperture == null)
            {
                return(null);
            }

            if (transform.IsIdentity)
            {
                return(new Aperture(aperture));
            }

            return(new Aperture(aperture, Transform(transform, aperture.PlanarBoundary3D)));
        }
Example #14
0
        public void AvailableAperturesTest()
        {
            ApertureEnum[] apertures = new[] { ApertureEnum.f9_5, ApertureEnum.f64 };

            ConfigureMockCamera(null, null, null, new IsoSpeedEnum[] { }, apertures, new ExposalEnum[] { }, new ImageQualityEnum[] { }, IsoSpeedEnum.iso6, ApertureEnum.f0, ExposalEnum.tBulb, ImageQualityEnum.PPT_sRAW1);

            CameraInfo cameraInfo = new CameraInfo(_camera);

            Assert.AreEqual(apertures.Length, cameraInfo.AvailableApertures.Count);
            Assert.That(cameraInfo.AvailableApertures, NUnit.Framework.Has.Member(Aperture.With(apertures[0])));
            Assert.That(cameraInfo.AvailableApertures, NUnit.Framework.Has.Member(Aperture.With(apertures[1])));

            _mockery.VerifyAllExpectationsHaveBeenMet();
        }
Example #15
0
        public static Opening TogbXML(this Aperture aperture, int cADObjectIdSufix = -1, double tolerance = Core.Tolerance.MicroDistance)
        {
            if (aperture == null)
            {
                return(null);
            }

            PlanarBoundary3D planarBoundary3D = aperture.PlanarBoundary3D;

            if (planarBoundary3D == null)
            {
                return(null);
            }

            ApertureConstruction apertureConstruction = aperture.ApertureConstruction;

            if (apertureConstruction == null)
            {
                return(null);
            }

            string name = aperture.Name;

            if (string.IsNullOrWhiteSpace(name))
            {
                name = aperture.ApertureConstruction.Name;
            }

            Opening opening = new Opening();

            //opening.constructionIdRef = Core.gbXML.Query.Id(aperture.ApertureConstruction, typeof(gbXMLSerializer.Construction));
            opening.Description = name;
            opening.id          = Core.gbXML.Query.Id(aperture, typeof(Opening));

            if (cADObjectIdSufix == -1)
            {
                opening.Name = string.Format("{0} [{1}]", name, aperture.Guid);
            }
            else
            {
                opening.Name = string.Format("{0} [{1}]", name, cADObjectIdSufix);
            }

            opening.openingType = Query.OpeningTypeEnum(aperture.ApertureConstruction.ApertureType);
            opening.pg          = planarBoundary3D.TogbXML(tolerance);
            opening.rg          = planarBoundary3D.TogbXML_RectangularGeometry(tolerance);
            opening.CADObjectId = Query.CADObjectId(aperture, cADObjectIdSufix);

            return(opening);
        }
Example #16
0
    void Awake()
    {
        if (Aperture.i != null)
        {
            Destroy(gameObject);
        }
        else
        {
            i = this;
            // DontDestroyOnLoad(gameObject);
        }

        cam = GetComponent <Camera>();
    }
Example #17
0
        public void GetApertureAvailableValuesTest()
        {
            int[] rawValues = new int[] { (int)ApertureEnum.f1, (int)ApertureEnum.f64, (int)ApertureEnum.f9 };
            Expect.Once.On(_camera).Method("GetAvailableValues").With(EDSDKLib.EDSDK.PropID_Av).Will(Return.Value(rawValues));

            EnumValueCollection values = Aperture.GetListFrom(_camera);

            Assert.AreEqual(rawValues.Length, values.Count);

            CheckValue(rawValues, values, 0, "F1");
            CheckValue(rawValues, values, 1, "F64");
            CheckValue(rawValues, values, 2, "F9");

            _mockery.VerifyAllExpectationsHaveBeenMet();
        }
Example #18
0
        public static Aperture ToSAM(this TAS3D.window window)
        {
            if (window == null)
            {
                return(null);
            }

            ParameterSet parameterSet = Create.ParameterSet(ActiveSetting.Setting, window);

            Aperture aperture = new Aperture(new ApertureConstruction(window.name, ApertureType.Window), null);

            aperture.Add(parameterSet);

            return(aperture);
        }
Example #19
0
        public static window ToT3D(this Aperture aperture, Building building)
        {
            if (aperture == null)
            {
                return(null);
            }

            uint colour;

            if (!Core.Query.TryGetValue(aperture, "Colour", out colour))
            {
                colour = Core.Convert.ToUint(Color.Black);
            }

            double width  = double.NaN;
            double height = double.NaN;
            double level  = double.NaN;

            PlanarBoundary3D planarBoundary3D = aperture.PlanarBoundary3D;

            if (planarBoundary3D == null)
            {
                if (!Core.Query.TryGetValue(aperture, "Width", out width))
                {
                    return(null);
                }

                if (!Core.Query.TryGetValue(aperture, "Height", out height))
                {
                    return(null);
                }

                if (!Core.Query.TryGetValue(aperture, "Level", out level))
                {
                    return(null);
                }
            }
            else
            {
                width  = planarBoundary3D.Width();
                height = planarBoundary3D.Height();
                level  = Analytical.Query.MinElevation(planarBoundary3D);
            }

            window result = building.AddWindow(aperture.Name, Query.OpeningType(aperture), colour, height, width, level);

            return(result);
        }
Example #20
0
        public string Generate()
        {
            string gerber = "";

            if (Points.Count > 1)
            {
                gerber += Aperture.Generate();
                gerber += Interpolation.Linear;
                gerber += Points[0].Generate(Operation.Move);
                for (int i = 1; i < Points.Count; i++)
                {
                    gerber += Points[i].Generate(Operation.Draw);
                }
            }
            return(gerber);
        }
Example #21
0
        public static FamilyInstance ToRevit(this Aperture aperture, Document document, Core.Revit.ConvertSettings convertSettings)
        {
            if (aperture == null || document == null)
            {
                return(null);
            }

            HostObject hostObject = Query.HostObject(aperture, document);

            if (hostObject == null)
            {
                return(null);
            }

            return(ToRevit(aperture, document, hostObject, convertSettings));
        }
Example #22
0
        public void EnumFieldsTest()
        {
            IsoSpeedEnum     iso          = IsoSpeedEnum.iso640;
            ApertureEnum     aperture     = ApertureEnum.f72;
            ExposalEnum      exposal      = ExposalEnum.t6;
            ImageQualityEnum imageQuality = ImageQualityEnum.PPT_sRAW1;

            ConfigureMockCamera(null, null, null, new IsoSpeedEnum[] { }, new ApertureEnum[] { }, new ExposalEnum[] { }, new ImageQualityEnum[] { }, iso, aperture, exposal, imageQuality);

            CameraInfo cameraInfo = new CameraInfo(_camera);

            Assert.AreEqual(IsoSpeed.With(iso), cameraInfo.CurrentIsoSpeed);
            Assert.AreEqual(Aperture.With(aperture), cameraInfo.CurrentAperture);
            Assert.AreEqual(Exposal.With(exposal), cameraInfo.CurrentExposal);
            Assert.AreEqual(ImageQuality.With(imageQuality), cameraInfo.CurrentImageQuality);

            _mockery.VerifyAllExpectationsHaveBeenMet();
        }
Example #23
0
        public static CADObjectId CADObjectId(this Aperture aperture, int cADObjectIdSufix = -1)
        {
            if (aperture == null)
            {
                return(null);
            }

            string uniqueName = Analytical.Query.UniqueName(aperture, cADObjectIdSufix);

            if (string.IsNullOrEmpty(uniqueName))
            {
                return(null);
            }

            CADObjectId cADObjectId = new CADObjectId();

            cADObjectId.id = uniqueName;

            return(cADObjectId);
        }
        public void CreateApertureBracketingTest()
        {
            ShootParameters parameters = new ShootParameters(IsoSpeedEnum.iso50, ApertureEnum.f5_6, ExposalEnum.t1_80);

            Aperture[] apertures = new Aperture[] { (Aperture)Aperture.Apertures.AtKey(ApertureEnum.f2), (Aperture)Aperture.Apertures.AtKey(ApertureEnum.f91) };


            Expect.Once.On(_camera).Method("GetAvailableValues").With(EDSDK.PropID_Tv).Will(Return.Value(
                                                                                                new int[]
            {
                (int)ExposalEnum.t30,
                (int)ExposalEnum.t1,
                (int)ExposalEnum.t1_60,
                (int)ExposalEnum.t1_80,
                (int)ExposalEnum.t1_100,
                (int)ExposalEnum.t1_125,
                (int)ExposalEnum.t1_4000
            }));
            Expect.Once.On(_camera).Method("GetAvailableValues").With(EDSDK.PropID_Av).Will(Return.Value(
                                                                                                new int[]
            {
                (int)ApertureEnum.f1,
                (int)ApertureEnum.f2,
                (int)ApertureEnum.f3_5,
                (int)ApertureEnum.f5_6,
                (int)ApertureEnum.f8,
                (int)ApertureEnum.f11,
                (int)ApertureEnum.f91
            }));

            CameraProcessor processor = new CameraProcessor(_camera, _cameraInfo);

            IShootParameters[] apertureBracketing = processor.CreateApertureBracketing(parameters, apertures);

            Assert.AreEqual(2, apertureBracketing.Length);
            Assert.AreEqual(new ShootParameters(IsoSpeedEnum.iso50, ApertureEnum.f2, ExposalEnum.t1_125), apertureBracketing[0]);
            Assert.AreEqual(new ShootParameters(IsoSpeedEnum.iso50, ApertureEnum.f91, ExposalEnum.t30), apertureBracketing[1]);

            _mockery.VerifyAllExpectationsHaveBeenMet();
        }
Example #25
0
        public static Aperture ToSAM(this gbXMLSerializer.Opening opening, double tolerance = Tolerance.MicroDistance)
        {
            if (opening == null)
            {
                return(null);
            }

            Polygon3D polygon3D = opening.pg.ToSAM(tolerance);

            if (polygon3D == null)
            {
                return(null);
            }

            ApertureType apertureType = Query.ApertureType(opening.openingType);

            ApertureConstruction apertureConstruction = new ApertureConstruction(opening.Name, apertureType);

            Aperture result = new Aperture(apertureConstruction, polygon3D);

            return(result);
        }
Example #26
0
        public static Log Log(this Aperture aperture, Document document)
        {
            if (aperture == null || document == null)
            {
                return(null);
            }

            Log result = new Log();

            Core.Modify.AddRange(result, Core.Revit.Create.Log(aperture, document));

            ApertureConstruction apertureConstruction = aperture.ApertureConstruction;

            if (apertureConstruction == null)
            {
                result.Add("Aperture {0} is missing ApertureConstruction Guid: {1}", LogRecordType.Error, aperture.Name, aperture.Guid);
            }

            result.AddRange(Log(apertureConstruction, document));

            return(result);
        }
        protected override void TrySolveInstance(IGH_DataAccess dataAccess)
        {
            bool run = false;

            if (!dataAccess.GetData(2, ref run) || !run)
            {
                return;
            }

            ConvertSettings convertSettings = null;

            dataAccess.GetData(1, ref convertSettings);
            convertSettings = this.UpdateSolutionEndEventHandler(convertSettings);

            Aperture aperture = null;

            if (!dataAccess.GetData(0, ref aperture))
            {
                return;
            }

            Document document = RhinoInside.Revit.Revit.ActiveDBDocument;

            Core.Revit.Modify.RemoveExisting(convertSettings, document, aperture);

            HostObject hostObject = Analytical.Revit.Query.HostObject(aperture, document);

            if (hostObject == null)
            {
                dataAccess.SetData(0, null);
                return;
            }

            FamilyInstance familyInstance_Revit = Analytical.Revit.Convert.ToRevit(aperture, document, hostObject, convertSettings);

            dataAccess.SetData(0, familyInstance_Revit);
        }
Example #28
0
        public string Generate()
        {
            string gerber = "";

            gerber += Aperture.Generate();
            gerber += Region.Enable;
            gerber += QuadrantMode.Multi;
            gerber += OutsideArc.Start.Generate(Operation.Move);

            gerber += Interpolation.CircularClockwise;
            gerber += Arc.Draw(OutsideArc.Start, OutsideArc.End, OutsideArc.Centre);

            gerber += Interpolation.Linear;
            gerber += InsideArc.End.Generate(Operation.Draw);

            gerber += Interpolation.CircularCounterClockwise;
            gerber += Arc.Draw(InsideArc.End, InsideArc.Start, InsideArc.Centre);

            gerber += Interpolation.Linear;
            gerber += OutsideArc.Start.Generate(Operation.Draw);

            gerber += Region.Disable;
            return(gerber);
        }
Example #29
0
        public static List <object> ToRhino(this Topology topology, double tolerance = Core.Tolerance.Distance)
        {
            if (topology == null)
            {
                return(null);
            }

            List <Object> geometries = new List <Object>();
            Vertex        vertex     = topology as Vertex;

            if (vertex != null)
            {
                geometries.Add(ToRhino(vertex));
                return(geometries);
            }

            Edge edge = topology as Edge;

            if (edge != null)
            {
                geometries.Add(ToRhino(edge));
                return(geometries);
            }

            Wire wire = topology as Wire;

            if (wire != null)
            {
                return(ToRhino(wire)?.Cast <object>().ToList());
            }

            global::Topologic.Face face = topology as global::Topologic.Face;
            if (face != null)
            {
                geometries.Add(ToRhino(face, tolerance));
                return(geometries);
            }

            Shell shell = topology as Shell;

            if (shell != null)
            {
                return(ToRhino_Breps(shell, tolerance)?.Cast <object>().ToList());
            }

            Cell cell = topology as Cell;

            if (cell != null)
            {
                return(ToRhino_Breps(cell, tolerance)?.Cast <object>().ToList());
            }

            CellComplex cellComplex = topology as CellComplex;

            if (cellComplex != null)
            {
                return(ToRhino_Breps((CellComplex)cellComplex, tolerance)?.Cast <object>().ToList());
            }

            Cluster cluster = topology as Cluster;

            if (cluster != null)
            {
                return(ToRhino(cluster.SubTopologies, tolerance));
            }

            Aperture aperture = topology as Aperture;

            if (aperture != null)
            {
                return(ToRhino(aperture.Topology, tolerance));
            }

            throw new Exception("The type of the input topology is not recognized.");
        }
            public MyForm()
            {
                //ClientSize = new Eto.Drawing.Size(400, 300);
                Title = "Eto.Forms";
                Width = 400;
                var md = new Model("id", new ModelProperties(ModelEnergyProperties.Default, ModelRadianceProperties.Default));

                var panel = new DynamicLayout();

                var ltn        = new LightingAbridged("lnt", 12, "Always On");
                var ltn2       = new LightingAbridged("lnt", 15, "Always On");
                var dlightCtrl = new DaylightingControl(new List <double>()
                {
                    0.5, 0.1, 0.5
                }, offAtMinimum: true);
                var ppl             = new PeopleAbridged("ppl", 0.1, "Always On", "Always On", latentFraction: new Autocalculate());
                var RoomPropertybtn = new Button()
                {
                    Text = "2 Rooms Property"
                };
                var rm1 = new Room($"Room1_{Guid.NewGuid()}_01021odjs", new List <Face>(), new RoomPropertiesAbridged(new RoomEnergyPropertiesAbridged("aaa", lighting: ltn)), "name1", multiplier: 1, story: "11");
                var rm2 = new Room($"Room2_{Guid.NewGuid()}_01021odjs", new List <Face>(), new RoomPropertiesAbridged(new RoomEnergyPropertiesAbridged("bbb", lighting: ltn2, people: ppl, daylightingControl: dlightCtrl)), "name2", multiplier: 2, story: "22");

                rm2.UserData = new { RhinoLayer = "layer 01", Color = "Red" };
                rm2          = rm2.DuplicateRoom();

                var rms = new List <Room>()
                {
                    rm1, rm2
                };

                RoomPropertybtn.Click += (s, e) =>
                {
                    var dialog = new Honeybee.UI.Dialog_RoomProperty(md.Properties, rms);
                    //dialog.SetSensorPositionPicker(() => { return new List<double>(); });
                    var dialog_rc = dialog.ShowModal(this);
                    if (dialog_rc != null)
                    {
                        foreach (var item in dialog_rc)
                        {
                            Console.WriteLine(item.ToJson(true));
                        }
                        rms = dialog_rc;
                    }
                };


                var RoomPropertybtn2 = new Button()
                {
                    Text = "1 Room Property"
                };

                RoomPropertybtn2.Click += (s, e) =>
                {
                    //md.Properties.Energy?.Hvacs = null;
                    var dialog = new Honeybee.UI.Dialog_RoomProperty(md.Properties, new List <Room>()
                    {
                        rm2
                    });
                    //dialog.SetSensorPositionPicker(() => { return new List<double>(); });
                    dialog.SetInternalMassPicker(() => 22);
                    var dialog_rc = dialog.ShowModal(this);
                    if (dialog_rc != null)
                    {
                        rm2 = dialog_rc.FirstOrDefault();
                        Console.WriteLine(rm2.ToJson(true));
                    }
                };

                var facePropertybtn = new Button()
                {
                    Text = "2 Faces Property"
                };
                var face  = new Face($"faceId_{Guid.NewGuid()}_01021odjs", new Face3D(new List <List <double> >()), FaceType.Floor, new Ground(), new FacePropertiesAbridged(new FaceEnergyPropertiesAbridged("aa"), new FaceRadiancePropertiesAbridged("bb", "cc")));
                var face2 = new Face($"Face_{Guid.NewGuid()}_01021odjs", new Face3D(new List <List <double> >()), FaceType.Wall, new Outdoors(), new FacePropertiesAbridged(new FaceEnergyPropertiesAbridged("Generic Exterior Wall")), "Face name");

                facePropertybtn.Click += (s, e) =>
                {
                    var dialog = new Honeybee.UI.Dialog_FaceProperty(md.Properties, new List <Face>()
                    {
                        face, face2
                    });
                    var dialog_rc = dialog.ShowModal(this);
                    if (dialog_rc != null)
                    {
                        foreach (var item in dialog_rc)
                        {
                            Console.WriteLine(item.ToJson(true));
                        }
                    }
                };

                var facePropertybtn2 = new Button()
                {
                    Text = "1 Face Property"
                };

                facePropertybtn2.Click += (s, e) =>
                {
                    var dialog = new Honeybee.UI.Dialog_FaceProperty(md.Properties, new List <Face>()
                    {
                        face2
                    });
                    var dialog_rc = dialog.ShowModal(this);
                    if (dialog_rc != null)
                    {
                        foreach (var item in dialog_rc)
                        {
                            Console.WriteLine(item.ToJson(true));
                        }
                    }
                };


                var aptPropertybtn = new Button()
                {
                    Text = "1 Apt Property"
                };
                var apt  = new Aperture($"aptId_{Guid.NewGuid()}_01021odjs", new Face3D(new List <List <double> >()), new Outdoors(), new AperturePropertiesAbridged(new ApertureEnergyPropertiesAbridged("aa"), new ApertureRadiancePropertiesAbridged("bb", "cc")));
                var apt2 = new Aperture($"Aperture_{Guid.NewGuid()}_01021odjs", new Face3D(new List <List <double> >()), new Outdoors(), new AperturePropertiesAbridged(new ApertureEnergyPropertiesAbridged("Generic Exterior Wall")), "apt name", isOperable: true);

                aptPropertybtn.Click += (s, e) =>
                {
                    var dialog = new Honeybee.UI.Dialog_ApertureProperty(md.Properties, new List <Aperture>()
                    {
                        apt2
                    });
                    var dialog_rc = dialog.ShowModal(this);
                    if (dialog_rc != null)
                    {
                        apt2 = dialog_rc.First();
                        foreach (var item in dialog_rc)
                        {
                            Console.WriteLine(item.ToJson(true));
                        }
                    }
                };
                var aptPropertybtn2 = new Button()
                {
                    Text = "2 Apts Property"
                };

                aptPropertybtn2.Click += (s, e) =>
                {
                    var dialog = new Honeybee.UI.Dialog_ApertureProperty(md.Properties, new List <Aperture>()
                    {
                        apt, apt2
                    });
                    var dialog_rc = dialog.ShowModal(this);
                    if (dialog_rc != null)
                    {
                        foreach (var item in dialog_rc)
                        {
                            Console.WriteLine(item.ToJson(true));
                        }
                    }
                };

                var doorPropertybtn = new Button()
                {
                    Text = "1 Door Property"
                };
                var door = new Door($"aptId_{Guid.NewGuid()}_01021odjs", new Face3D(new List <List <double> >()), new Outdoors(), new DoorPropertiesAbridged());

                doorPropertybtn.Click += (s, e) =>
                {
                    var dialog = new Honeybee.UI.Dialog_DoorProperty(md.Properties, new List <Door>()
                    {
                        door
                    });
                    var dialog_rc = dialog.ShowModal(this);
                    if (dialog_rc != null)
                    {
                        foreach (var item in dialog_rc)
                        {
                            Console.WriteLine(item.ToJson(true));
                        }
                    }
                };

                var shdPropertybtn = new Button()
                {
                    Text = "1 Shade Property"
                };
                var shd  = new Shade($"shdId_{Guid.NewGuid()}_01021odjs", new Face3D(new List <List <double> >()), new ShadePropertiesAbridged(new ShadeEnergyPropertiesAbridged("aa"), new ShadeRadiancePropertiesAbridged("bb", "cc")));
                var shd2 = new Shade($"Shade_{Guid.NewGuid()}_01021odjs", new Face3D(new List <List <double> >()), new ShadePropertiesAbridged(new ShadeEnergyPropertiesAbridged("Generic Exterior Wall")), "shd name", isDetached: true);

                shdPropertybtn.Click += (s, e) =>
                {
                    var dialog = new Honeybee.UI.Dialog_ShadeProperty(md.Properties, new List <Shade>()
                    {
                        shd2
                    });
                    var dialog_rc = dialog.ShowModal(this);
                    if (dialog_rc != null)
                    {
                        shd2 = dialog_rc.FirstOrDefault();
                        foreach (var item in dialog_rc)
                        {
                            Console.WriteLine(item.ToJson(true));
                        }
                    }
                };
                var shdPropertybtn2 = new Button()
                {
                    Text = "2 Shade Property"
                };

                shdPropertybtn2.Click += (s, e) =>
                {
                    var dialog = new Honeybee.UI.Dialog_ShadeProperty(md.Properties, new List <Shade>()
                    {
                        shd, shd2
                    });
                    var dialog_rc = dialog.ShowModal(this);
                    if (dialog_rc != null)
                    {
                        foreach (var item in dialog_rc)
                        {
                            Console.WriteLine(item.ToJson(true));
                        }
                    }
                };

                var view = new HoneybeeSchema.View("id", new List <double>()
                {
                    1, 1, 1
                }, new List <double>()
                {
                    2, 2, 2
                }, new List <double>()
                {
                    0, 0, 1
                }, viewType: ViewType.c);
                var view2 = new HoneybeeSchema.View("id2", new List <double>()
                {
                    1, 1, 1
                }, new List <double>()
                {
                    2, 2, 2
                }, new List <double>()
                {
                    0, 0, 1
                }, hSize: 120, vSize: 120);

                var viewPropertybtn = new Button()
                {
                    Text = "1 view Property"
                };

                viewPropertybtn.Click += (s, e) =>
                {
                    var dialog = new Honeybee.UI.Dialog_ViewProperty(new List <HoneybeeSchema.View>()
                    {
                        view
                    });
                    var dialog_rc = dialog.ShowModal(this);
                    if (dialog_rc != null)
                    {
                        foreach (var item in dialog_rc)
                        {
                            Console.WriteLine(item.ToJson(true));
                        }
                    }
                };
                var viewPropertybtn2 = new Button()
                {
                    Text = "2 view Property"
                };

                viewPropertybtn2.Click += (s, e) =>
                {
                    var dialog = new Honeybee.UI.Dialog_ViewProperty(new List <HoneybeeSchema.View>()
                    {
                        view, view2
                    });
                    var dialog_rc = dialog.ShowModal(this);
                    if (dialog_rc != null)
                    {
                        foreach (var item in dialog_rc)
                        {
                            Console.WriteLine(item.ToJson(true));
                        }
                    }
                };

                var sensorGrid  = new SensorGrid("id", new List <Sensor>());
                var sensorGrid2 = new SensorGrid("id2", new List <Sensor>(), groupIdentifier: "sdfd");

                var sensorGridPropertybtn = new Button()
                {
                    Text = "1 sensor grid Property"
                };

                sensorGridPropertybtn.Click += (s, e) =>
                {
                    var dialog = new Honeybee.UI.Dialog_SensorGridProperty(new List <SensorGrid>()
                    {
                        sensorGrid2
                    });
                    var dialog_rc = dialog.ShowModal(this);
                    if (dialog_rc != null)
                    {
                        foreach (var item in dialog_rc)
                        {
                            Console.WriteLine(item.ToJson(true));
                        }
                    }
                };
                var sensorGridPropertybtn2 = new Button()
                {
                    Text = "2 sensor grid Property"
                };

                sensorGridPropertybtn2.Click += (s, e) =>
                {
                    var dialog = new Honeybee.UI.Dialog_SensorGridProperty(new List <SensorGrid>()
                    {
                        sensorGrid, sensorGrid2
                    });
                    var dialog_rc = dialog.ShowModal(this);
                    if (dialog_rc != null)
                    {
                        foreach (var item in dialog_rc)
                        {
                            Console.WriteLine(item.ToJson(true));
                        }
                    }
                };

                var Messagebtn = new Button()
                {
                    Text = "message text"
                };

                Messagebtn.Click += (s, e) =>
                {
                    var energyProp = new HoneybeeSchema.RoomEnergyPropertiesAbridged();
                    Dialog_Message.Show(this, energyProp.ToJson());
                };

                var cSetbtn = new Button()
                {
                    Text = "ConstructionSet"
                };

                cSetbtn.Click += (s, e) =>
                {
                    var lib    = md.Properties.Energy;
                    var cSet   = new HoneybeeSchema.ConstructionSetAbridged(identifier: Guid.NewGuid().ToString());
                    var dialog = new Honeybee.UI.Dialog_ConstructionSet(ref lib, cSet);
                    var rs     = dialog.ShowModal(this);
                    if (rs != null)
                    {
                        Dialog_Message.Show(this, rs.ToJson());
                    }
                };

                var pTypebtn = new Button()
                {
                    Text = "ProgramType"
                };

                pTypebtn.Click += (s, e) =>
                {
                    var pType  = new HoneybeeSchema.ProgramTypeAbridged(identifier: Guid.NewGuid().ToString());
                    var lib    = md.Properties;
                    var dialog = new Honeybee.UI.Dialog_ProgramType(ref lib, pType);
                    dialog.ShowModal(this);
                };

                var pTypeMngbtn = new Button()
                {
                    Text = "ProgramTypeManager"
                };

                pTypeMngbtn.Click += (s, e) =>
                {
                    var lib       = md.Properties;
                    var dialog    = new Honeybee.UI.Dialog_ProgramTypeManager(ref lib);
                    var dialog_rc = dialog.ShowModal(this);
                };

                var schbtn = new Button()
                {
                    Text = "ScheduleRulesetManager"
                };

                schbtn.Click += (s, e) =>
                {
                    var lib       = md.Properties.Energy;
                    var dialog    = new Honeybee.UI.Dialog_ScheduleRulesetManager(ref lib);
                    var dialog_rc = dialog.ShowModal(this);
                };

                var conbtn = new Button()
                {
                    Text = "ConstructionManager"
                };

                conbtn.Click += (s, e) =>
                {
                    var lib    = md.Properties.Energy;
                    var dialog = new Honeybee.UI.Dialog_ConstructionManager(ref lib);
                    dialog.ShowModal(this);
                };

                var cSetManager = new Button()
                {
                    Text = "ConstructionSet Manager"
                };

                cSetManager.Click += (s, e) =>
                {
                    var lib    = md.Properties.Energy;
                    var dialog = new Dialog_ConstructionSetManager(ref lib);
                    dialog.ShowModal(this);
                };

                var simuParam = new Button()
                {
                    Text = "Simulation Parameter"
                };

                simuParam.Click += (s, e) =>
                {
                    var sP     = new SimulationParameter();
                    var dialog = new Honeybee.UI.Dialog_SimulationParameter(sP);
                    dialog.ShowModal(this);
                };

                var modelManager = new Button()
                {
                    Text = "Model Resource"
                };

                modelManager.Click += (s, e) =>
                {
                    var dialog = new Honeybee.UI.Dialog_ModelResources(md);
                    dialog.ShowModal(this);
                };

                var materialBtn = new Button()
                {
                    Text = "Material Manager"
                };

                materialBtn.Click += (s, e) =>
                {
                    var lib          = md.Properties.Energy;
                    var dialog       = new Honeybee.UI.Dialog_MaterialManager(ref lib);
                    var newMaterials = dialog.ShowModal(this);
                    if (newMaterials != null)
                    {
                        md.Properties.Energy.Materials.Clear();
                        md.AddMaterials(newMaterials);
                    }
                };


                var modifierBtn = new Button()
                {
                    Text = "Modifier Manager"
                };

                modifierBtn.Click += (s, e) =>
                {
                    var lib    = md.Properties.Radiance;
                    var dialog = new Honeybee.UI.Dialog_ModifierManager(ref lib);

                    var dialog_rc = dialog.ShowModal(this);
                    if (dialog_rc != null)
                    {
                        md.Properties.Radiance.Modifiers.Clear();
                        md.AddModifiers(dialog_rc);
                    }
                };

                var modifierSetMngBtn = new Button()
                {
                    Text = "ModifierSet Manager"
                };

                modifierSetMngBtn.Click += (s, e) =>
                {
                    var lib    = md.Properties.Radiance;
                    var dialog = new Honeybee.UI.Dialog_ModifierSetManager(ref lib);

                    var dialog_rc = dialog.ShowModal(this);
                    if (dialog_rc != null)
                    {
                        md.Properties.Radiance.ModifierSets.Clear();
                        md.AddModifierSets(dialog_rc);
                    }
                };

                var modifierSetBtn = new Button()
                {
                    Text = "ModifierSet Editor"
                };

                modifierSetBtn.Click += (s, e) =>
                {
                    var dup    = new ModifierSetAbridged("NewModifierSet");
                    var lib    = md.Properties.Radiance;
                    var dialog = new Honeybee.UI.Dialog_ModifierSet(ref lib, dup);

                    var dialog_rc = dialog.ShowModal(this);
                };


                var shwMngBtn = new Button()
                {
                    Text = "SHW Manager"
                };

                shwMngBtn.Click += (s, e) =>
                {
                    var lib    = md.Properties.Energy;
                    var dialog = new Honeybee.UI.Dialog_SHWManager(ref lib);

                    var dialog_rc = dialog.ShowModal(this);
                };

                var shwBtn = new Button()
                {
                    Text = "SHW Editor"
                };

                shwBtn.Click += (s, e) =>
                {
                    var dialog    = new Honeybee.UI.Dialog_SHW();
                    var dialog_rc = dialog.ShowModal(this);
                };

                var outputs = new Button()
                {
                    Text = "EPOutputs"
                };

                outputs.Click += (s, e) =>
                {
                    var epoutput = new SimulationOutput();
                    var dialog   = new Honeybee.UI.Dialog_EPOutputs(epoutput);
                    dialog.ShowModal(this);
                };


                var opsHVACs = new Button()
                {
                    Text = "OpenStudioHVACs"
                };

                opsHVACs.Click += (s, e) =>
                {
                    var lib    = md.Properties.Energy;
                    var dialog = new Honeybee.UI.Dialog_OpsHVACs(ref lib);
                    dialog.ShowModal(this);
                };

                var HVACManager = new Button()
                {
                    Text = "HVACsManager"
                };

                HVACManager.Click += (s, e) =>
                {
                    var lib    = md.Properties.Energy;
                    var dialog = new Honeybee.UI.Dialog_HVACManager(ref lib);
                    dialog.ShowModal(this);
                };

                var cSetSel_btn = new Button()
                {
                    Text = "CSetSelector"
                };

                cSetSel_btn.Click += (s, e) =>
                {
                    var lib        = md.Properties.Energy;
                    var cSetSel    = new Dialog_ConstructionSetManager(ref lib, true);
                    var cSetSel_rc = cSetSel.ShowModal(Config.Owner);
                    if (cSetSel_rc != null)
                    {
                        foreach (var item in md.Properties.Energy.ConstructionSets)
                        {
                            Console.WriteLine(item.Obj);
                        }
                    }
                };

                var cIntSetSel_btn = new Button()
                {
                    Text = "ConstructionSet Interior"
                };
                var cInt = new InteriorSet();

                cIntSetSel_btn.Click += (s, e) =>
                {
                    var lib        = md.Properties.Energy;
                    var cSetSel    = new Dialog_ConstructionSet_Interior(ref lib, cInt);
                    var cSetSel_rc = cSetSel.ShowModal(Config.Owner);
                    if (cSetSel_rc != null)
                    {
                        cInt = cSetSel_rc;
                        Console.WriteLine(cSetSel_rc);
                    }
                };

                var mIntSetSel_btn = new Button()
                {
                    Text = "ModifierSet Interior"
                };
                var mInt = new InteriorSet();

                mIntSetSel_btn.Click += (s, e) =>
                {
                    var lib        = md.Properties.Radiance;
                    var cSetSel    = new Dialog_ModifierSet_Interior(ref lib, mInt);
                    var cSetSel_rc = cSetSel.ShowModal(Config.Owner);
                    if (cSetSel_rc != null)
                    {
                        mInt = cSetSel_rc;
                        Console.WriteLine(cSetSel_rc);
                    }
                };


                var matchRooms_btn = new Button()
                {
                    Text = "MatchRooms"
                };

                matchRooms_btn.Click += (s, e) =>
                {
                    var source = new Room("id", new List <Face>(), new RoomPropertiesAbridged(energy: new RoomEnergyPropertiesAbridged("my construction")), displayName: "SourceName");
                    var target = new Room("id", new List <Face>(), new RoomPropertiesAbridged());
                    var dia    = new Dialog_MatchRoomProperties(source, new List <Room>()
                    {
                        target
                    });
                    var rc = dia.ShowModal(Config.Owner);
                    if (rc != null)
                    {
                        foreach (var item in rc)
                        {
                            Console.WriteLine(item.ToJson());
                        }
                    }
                };

                var lockedUnits = new Dictionary <Honeybee.UI.Units.UnitType, System.Enum>()
                {
                    { Honeybee.UI.Units.UnitType.Length, Units.LengthUnit.Millimeter }
                };
                var unit_btn = new Button()
                {
                    Text = "Unit setting"
                };

                unit_btn.Click += (s, e) =>
                {
                    var dia = new Dialog_UnitSetting(lockedUnits);
                    dia.ShowModal(Config.Owner);
                };


                var legend_btn = new Button()
                {
                    Text = "Legend"
                };

                legend_btn.Click += (s, e) =>
                {
                    var dia = new Dialog_Legend(null);
                    dia.ShowModal(Config.Owner);
                };

                var errors_btn = new Button()
                {
                    Text = "Errors"
                };
                //var validationReport = new ValidationReport()
                //var path = @"D:\Dev\Pollination\rhino-plugin\error.json";
                //var json = System.IO.File.ReadAllText(path);
                var report = new ValidationReport("1.1.0", "1.2.0", false, "Error");

                errors_btn.Click += (s, e) =>
                {
                    var dia = Dialog_Error.Instance;
                    dia.Update(report);
                    dia.Show();
                };

                panel.AddSeparateRow(RoomPropertybtn, RoomPropertybtn2, null);
                panel.AddSeparateRow(facePropertybtn, facePropertybtn2, null);
                panel.AddSeparateRow(aptPropertybtn, aptPropertybtn2, null);
                panel.AddSeparateRow(doorPropertybtn, null);
                panel.AddSeparateRow(shdPropertybtn, shdPropertybtn2, null);
                panel.AddSeparateRow(viewPropertybtn, viewPropertybtn2, null);
                panel.AddSeparateRow(sensorGridPropertybtn, sensorGridPropertybtn2, null);
                panel.AddSeparateRow(Messagebtn);
                panel.AddSeparateRow(conbtn, cSetbtn, cIntSetSel_btn, cSetManager, cSetSel_btn, null);
                panel.AddSeparateRow(pTypebtn, pTypeMngbtn, null);
                panel.AddSeparateRow(schbtn);
                panel.AddSeparateRow(simuParam);
                panel.AddSeparateRow(modelManager);
                panel.AddSeparateRow(materialBtn);
                panel.AddSeparateRow(modifierBtn, modifierSetMngBtn, modifierBtn, mIntSetSel_btn, null);
                panel.AddSeparateRow(shwMngBtn, shwBtn);
                panel.AddSeparateRow(outputs);
                panel.AddSeparateRow(opsHVACs);
                panel.AddSeparateRow(HVACManager);
                panel.AddSeparateRow(matchRooms_btn);
                panel.AddSeparateRow(unit_btn, legend_btn);
                panel.AddSeparateRow(errors_btn);
                panel.AddSeparateRow(null);
                Content = panel;
            }