Example #1
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            //
            FemDesign.Model model            = null;
            string          filePath         = null;
            bool            closeOpenWindows = false;

            // get data
            if (!DA.GetData(0, ref model))
            {
                return;
            }
            if (!DA.GetData(1, ref filePath))
            {
                return;
            }
            if (!DA.GetData(2, ref closeOpenWindows))
            {
                // pass
            }

            bool runNode = true;

            if (!DA.GetData(3, ref runNode))
            {
                // pass
            }

            if (model == null || filePath == null)
            {
                return;
            }

            //
            if (runNode)
            {
                model.SerializeModel(filePath);
                model.FdApp.OpenStruxml(filePath, closeOpenWindows);
            }
            else
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "RunNode is set to false!");
            }
        }
Example #2
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            //
            string mode = null;

            FemDesign.Model model    = null;
            string          filePath = null;

            FemDesign.Calculate.Analysis analysis = null;
            FemDesign.Calculate.Design   design   = null;
            List <string> resultTypes             = new List <string>();
            string        docxTemplatePath        = "";
            bool          endSession       = false;
            bool          closeOpenWindows = false;
            bool          runNode          = false;


            // get data
            if (!DA.GetData(0, ref mode))
            {
                return;
            }
            if (!DA.GetData(1, ref model))
            {
                return;
            }
            if (!DA.GetData(2, ref filePath))
            {
                return;
            }
            if (!DA.GetData(3, ref analysis))
            {
                return;
            }
            if (!DA.GetData(4, ref design))
            {
                return;
            }
            if (!DA.GetDataList(5, resultTypes))
            {
                // pass
            }

            var units = Results.UnitResults.Default();

            DA.GetData(6, ref units);

            if (!DA.GetData(7, ref docxTemplatePath))
            {
                // pass
            }
            if (!DA.GetData(8, ref endSession))
            {
                // pass
            }
            if (!DA.GetData(9, ref closeOpenWindows))
            {
                // pass
            }
            if (!DA.GetData(10, ref runNode))
            {
                // pass
            }
            if (mode == null || model == null || filePath == null || analysis == null)
            {
                return;
            }

            // It needs to check if model has been runned
            // Always Return the FeaNode Result
            resultTypes.Insert(0, "FeaNode");
            resultTypes.Insert(1, "FeaBar");
            resultTypes.Insert(2, "FeaShell");


            var _resultTypes = resultTypes.Select(r => GenericClasses.EnumParser.Parse <Results.ResultType>(r));

            var bscPathsFromResultTypes = Calculate.Bsc.BscPathFromResultTypes(_resultTypes, filePath, units);

            bool rtn         = false;
            var  resultsTree = new DataTree <object>();

            Results.FDfea fdFeaModel = null;



            //
            if (runNode)
            {
                model.SerializeModel(filePath);
                analysis.SetLoadCombinationCalculationParameters(model);
                rtn = model.FdApp.RunDesign(mode, filePath, analysis, design, bscPathsFromResultTypes, docxTemplatePath, endSession, closeOpenWindows);


                // Create FdScript
                var fdScript = FemDesign.Calculate.FdScript.ReadStr(filePath, bscPathsFromResultTypes);

                IEnumerable <Results.IResult> results = Enumerable.Empty <Results.IResult>();

                List <Results.FeaNode>  feaNodeRes  = new List <Results.FeaNode>();
                List <Results.FeaBar>   feaBarRes   = new List <Results.FeaBar>();
                List <Results.FeaShell> feaShellRes = new List <Results.FeaShell>();

                if (resultTypes != null && resultTypes.Any())
                {
                    foreach (var cmd in fdScript.CmdListGen)
                    {
                        string path = cmd.OutFile;
                        try
                        {
                            if (path.Contains("FeaNode"))
                            {
                                feaNodeRes = Results.ResultsReader.Parse(path).Cast <Results.FeaNode>().ToList();
                            }
                            else if (path.Contains("FeaBar"))
                            {
                                feaBarRes = Results.ResultsReader.Parse(path).Cast <Results.FeaBar>().ToList();
                            }
                            else if (path.Contains("FeaShell"))
                            {
                                feaShellRes = Results.ResultsReader.Parse(path).Cast <Results.FeaShell>().ToList();
                            }
                            else
                            {
                                var _results = Results.ResultsReader.Parse(path);
                                results = results.Concat(_results);
                            }
                        }
                        catch (Exception e)
                        {
                            throw new Exception(e.InnerException.Message);
                        }
                    }
                }

                fdFeaModel = new FemDesign.Results.FDfea(feaNodeRes, feaBarRes, feaShellRes);

                var resultGroups = results.GroupBy(t => t.GetType()).ToList();

                // Convert Data in DataTree structure
                var i = 0;
                foreach (var resGroup in resultGroups)
                {
                    resultsTree.AddRange(resGroup.AsEnumerable(), new GH_Path(i));
                    i++;
                }
            }
            else
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "RunNode is set to false!");
            }

            // Set output
            DA.SetData("FdModel", model);
            DA.SetData("FdFeaModel", fdFeaModel);
            DA.SetDataTree(2, resultsTree);
            DA.SetData(3, rtn);
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            //
            FemDesign.Model model    = null;
            string          filePath = null;

            FemDesign.Calculate.Analysis analysis = null;
            List <string> bscPath          = new List <string>();
            string        docxTemplatePath = "";
            bool          endSession       = false;
            bool          closeOpenWindows = false;
            bool          runNode          = false;

            // get data
            if (!DA.GetData(0, ref model))
            {
                return;
            }
            if (!DA.GetData(1, ref filePath))
            {
                return;
            }
            if (!DA.GetData(2, ref analysis))
            {
                return;
            }
            if (!DA.GetDataList(3, bscPath))
            {
                // pass
            }
            if (!DA.GetData(4, ref docxTemplatePath))
            {
                // pass
            }
            if (!DA.GetData(5, ref endSession))
            {
                // pass
            }
            if (!DA.GetData(6, ref closeOpenWindows))
            {
                // pass
            }
            if (!DA.GetData(7, ref runNode))
            {
                // pass
            }
            if (model == null || filePath == null || analysis == null)
            {
                return;
            }

            //
            if (runNode)
            {
                model.SerializeModel(filePath);
                analysis.SetLoadCombinationCalculationParameters(model);
                bool rtn = model.FdApp.RunAnalysis(filePath, analysis, bscPath, docxTemplatePath, endSession, closeOpenWindows);
                DA.SetData(0, rtn);
            }
            else
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "RunNode is set to false!");
            }
        }