Exemplo n.º 1
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            string      inx          = null;
            bool        runIt        = false;
            GridEnvimet envimentGrid = null;

            DA.GetData(0, ref inx);
            DA.GetData(1, ref envimentGrid);
            DA.GetData(2, ref runIt);

            if (runIt)
            {
                var modelgeometry = Facade.GetGridDetail(inx);

                if (modelgeometry == null)
                {
                    this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "It works only with 3d detailed model for now.\n" +
                                           "Please, use ENVI-Met Spaces to convert your 2.5D model into 3D model.");
                    return;
                }

                if (envimentGrid == null)
                {
                    envimentGrid = ReadEnvimet.GetGridFromInx(modelgeometry);
                }

                var mesh = GridOutput.GetAnalysisMesh(envimentGrid, Direction);

                DA.SetData(0, mesh);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            string _outputFolder = null;

            DA.GetData(0, ref _outputFolder);

            string outputPath = Path.Combine(_outputFolder, _value);
            IEnumerable <string> gridFiles       = new List <string>();
            IEnumerable <string> gridBinaryFiles = new List <string>();

            gridFiles       = GridOutput.GetAllGridFiles(outputPath, GridOutputExtension.Standard);
            gridBinaryFiles = GridOutput.GetAllGridFiles(outputPath, GridOutputExtension.Binary);

            DA.SetDataList(0, gridFiles);
            DA.SetDataList(1, gridBinaryFiles);
            DA.SetData(2, _value);
        }
Exemplo n.º 3
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            List <string> gridFiles       = new List <string>();
            List <string> gridBinaryFiles = new List <string>();
            string        type            = GridOutputFolderType.ATMOSPHERE;
            int           var             = 0;
            int           loc             = 0;
            bool          runIt           = false;

            DA.GetDataList(0, gridFiles);
            DA.GetDataList(1, gridBinaryFiles);
            DA.GetData(2, ref type);
            DA.GetData(3, ref var);
            DA.GetData(4, ref loc);
            DA.GetData(5, ref runIt);

            GetNameOfPlaneInput();
            ChangeVariableDescription(type);


            if (runIt)
            {
                var    variables        = GetVariable();
                int    selectedVariable = 0;
                object varName          = null;
                string report           = String.Empty;

                switch (type)
                {
                case GridOutputFolderType.ATMOSPHERE:
                    var atmosphere = variables[0] as List <AtmosphereOutput>;
                    // Warning
                    if (var >= atmosphere.Count)
                    {
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Atmosphere variable is out of range, check description of the input.");
                        return;
                    }
                    selectedVariable = (int)(atmosphere)[var];
                    varName          = atmosphere[var];
                    break;

                case GridOutputFolderType.POLLUTANTS:
                    var pollutant = variables[1] as List <PollutantsOutput>;
                    // Warning
                    if (var >= pollutant.Count)
                    {
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Pollutants variable is out of range, check description of the input.");
                        return;
                    }
                    selectedVariable = (int)(pollutant)[var];
                    varName          = pollutant[var];
                    break;

                case GridOutputFolderType.RADIATION:
                    var radiation = variables[2] as List <RadiationOutput>;
                    // Warning
                    if (var >= radiation.Count)
                    {
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Radiation variable is out of range, check description of the input.");
                        return;
                    }
                    selectedVariable = (int)(radiation)[var];
                    varName          = radiation[var];
                    break;

                case GridOutputFolderType.SOIL:
                    var soil = variables[3] as List <SoilOutput>;
                    // Warning
                    if (var >= soil.Count)
                    {
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Soil variable is out of range, check description of the input.");
                        return;
                    }
                    selectedVariable = (int)(soil)[var];
                    varName          = soil[var];
                    break;

                case GridOutputFolderType.SURFACE:
                    var surface = variables[4] as List <SurfaceOutput>;
                    // Warning
                    if (var >= surface.Count)
                    {
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Soil variable is out of range, check description of the input.");
                        return;
                    }
                    FlatResults();
                    loc = 0;
                    selectedVariable = (int)(surface)[var];
                    varName          = surface[var];
                    break;

                case GridOutputFolderType.SOLAR_ACCESS:
                    var solar = variables[5] as List <SolarAccessOutput>;
                    // Warning
                    if (var >= solar.Count)
                    {
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Solar access variable is out of range, check description of the input.");
                        return;
                    }
                    FlatResults();
                    selectedVariable = (int)(solar)[var];
                    varName          = solar[var];
                    break;

                case GridOutputFolderType.VEGETATIONS:
                    var vegetation = variables[6] as List <VegetationOutput>;
                    // Warning
                    if (var >= vegetation.Count)
                    {
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Vegetation variable is out of range, check description of the input.");
                        return;
                    }
                    selectedVariable = (int)(vegetation)[var];
                    varName          = vegetation[var];
                    break;
                }

                DataTree <string> fileNameTree = new DataTree <string>();
                DataTree <object> variableTree = new DataTree <object>();
                DataTree <double> dataTree     = new DataTree <double>();

                for (int i = 0; i < gridFiles.Count; i++)
                {
                    GHD.GH_Path pth = new GHD.GH_Path(i);
                    try
                    {
                        string edxName = Path.GetFileNameWithoutExtension(gridFiles[i]);
                        string edtName = Path.GetFileNameWithoutExtension(gridBinaryFiles[i]);

                        if (edxName == edtName)
                        {
                            List <double> results = GridOutput.ParseBinGrid(gridFiles[i], gridBinaryFiles[i], selectedVariable, loc, Direction);


                            if (results == null)
                            {
                                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Location of plane is out of range.");
                                return;
                            }

                            report = GridOutput.GetReport(gridFiles[i]);
                            DA.SetData(0, report);
                            Vector3d vector = GridOutput.GetVectorPlaneFromEdx(gridFiles[i], Direction, loc);
                            DA.SetData(1, vector);

                            fileNameTree.Add(Path.GetFileName(gridFiles[i]), pth);
                            variableTree.Add(varName, pth);
                            dataTree.AddRange(results, pth);
                        }
                        else
                        {
                            AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Please, check output folder you are reading. EDT file name and EDX file name should be the same.");
                        }
                    }
                    catch
                    {
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Something is wrong in output dynamic folder.\nPlease, make sure EDT length is equals to EDX length.");
                        continue;
                    }
                }

                DA.SetDataTree(2, fileNameTree);
                DA.SetDataTree(3, variableTree);
                DA.SetDataTree(4, dataTree);
            }
        }