/// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object can be used to retrieve data from input parameters and
        /// to store data in output parameters.</param>
        protected override void SolveInstance(IGH_DataAccess DA, EvaluationUnit unit)
        {
            // RFEM variables
            var        modelName = "";
            IModel     model     = null;
            IModelData data      = null;
            ILoads     loads     = null;

            // Assign GH Input
            bool   run       = false;
            var    scale     = 0.0;
            string iLoadCase = "";

            DA.GetData(0, ref run);
            DA.GetData(1, ref scale);

            // Do stuff
            if (run)
            {
                msg = new List <string>();

                if (!DA.GetData(5, ref modelName))
                {
                    Component_GetData.ConnectRFEM(ref model, ref data);
                }
                else
                {
                    Component_GetData.ConnectRFEM(modelName, ref model, ref data);
                }
                _saveddata = data;
                try
                {
                    // Get deformtions
                    _resetLC = true;
                    // Get loads
                    Component_GetData.GetLoadsFromRFEM(model, ref loads);
                    // Update load cases and combos to display in dropdown menu
                    _results = model.GetCalculation();

                    // Get load cases and combos to
                    var newLoadCasesAndCombos = new List <string>();
                    newLoadCasesAndCombos = loads.GetLoadCasesAndCombos(ref _countCases, ref _countCombos, ref _countRcombos);
                    if (_lCasesAndCombos == null || _lCasesAndCombos.Count == 0 || !_lCasesAndCombos.Equals(newLoadCasesAndCombos))
                    {
                        _lCasesAndCombos     = newLoadCasesAndCombos;
                        _loadDropLastValue   = 0; // reset dropdown menus if run
                        _resultDropLastValue = 0;
                        _lastLoadCase        = "";
                        _lastType            = 0;
                        _restoreDropDown     = true;
                    }
                    // Get deformed shape?
                    if (_deformationsCheck.Active)
                    {
                        _deformation_results = true;
                        // Get members
                        _rfMembers = Component_GetData.GetRFMembers(data.GetMembers().ToList(), data);
                        // Get Fe Meshes from RFEM
                        _rfemMesh = _results.GetFeMesh();
                        _feMeshes = CreateFEMeshes(ref msg);
                    }
                    else
                    {
                        _deformation_results = false;
                    }

                    // Disconnect RFEM
                    Component_GetData.DisconnectRFEM(ref model, ref data);

                    // Results are displayed just when the button is set to 0 - if no LC is provided
                    var dummyLC = "";
                    if (!DA.GetData(2, ref dummyLC))
                    {
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Set run to false to display results");
                        return;
                    }
                }
                catch (Exception ex)
                {
                    Component_GetData.DisconnectRFEM(ref model, ref data);
                    // Clear output!!!
                    _saveddata = null;
                    _rfemMesh  = null;
                    _results   = null;
                    _lcresults = null;
                    outResults = null;
                    _feMeshes.Clear();
                    _meshdisplacements.Clear();
                    _meshdisplacementsByType.Clear();
                    _deformedMeshes.Clear();
                    _controlPoints.Clear();
                    _memberdisplacements.Clear();
                    _memberdisplacementsByType.Clear();
                    _deformedMembers.Clear();
                    _sfcNo.Clear();
                    _memberNo.Clear();
                    _deformation_results = false;
                    throw ex;
                }
            }

            // do stuff
            if (msg.Count == 0) // if there are no calculation errors
            {
                // Get Load Case Number and result type
                int    result_type      = 0;
                string result_type_name = "";
                if (DA.GetData(2, ref iLoadCase))
                {
                    if (DA.GetData(3, ref result_type))
                    {
                        if (result_type <= 0 || result_type > Enum.GetNames(typeof(ResultsValueType)).Length - 1)
                        {
                            _loadDrop.Clear();
                            _resulttypeDrop.Clear();
                            _restoreDropDown = true; // for next time
                            AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Provide Valid Result Type.");
                            return;
                        }
                        result_type_name = Enum.GetName(typeof(ResultsValueType), result_type);
                        if (_lastLoadCase != iLoadCase || _lastType != result_type) // otherwise execution comes from change in scale and no need to reset load case
                        {
                            _resetLC = true;
                        }
                        _loadDrop.Clear();
                        _resulttypeDrop.Clear();
                        _restoreDropDown = true; // for next time
                    }
                    else
                    {
                        _loadDrop.Clear();
                        _resulttypeDrop.Clear();
                        _restoreDropDown = true; // for next time
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Provide Result Type.");
                        return;
                    }
                }
                else if (DA.GetData(3, ref result_type))
                {
                    _loadDrop.Clear();
                    _resulttypeDrop.Clear();
                    _restoreDropDown = true; // for next time
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Provide Load Case or Combo.");
                    return;
                }
                else // get values from dropdown menus
                {
                    if (_lCasesAndCombos.Count == 0)
                    {
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "No results to display");
                        _loadDrop.Clear();
                        _resulttypeDrop.Clear();
                        return;
                    }
                    if (_restoreDropDown) // from previous execution when it was overwritten
                    {
                        updateDropDownMenu(_lCasesAndCombos);
                        _resetLC         = true;
                        _restoreDropDown = false; // for next time
                    }
                    iLoadCase = _loadDrop.Items[_loadDrop.Value].name;
                }

                // Get results to display
                // 1) Results from load case or combo for all types 2) Results for selected result type 3) Apply scale
                if (_resetLC)
                {
                    int no    = Int16.Parse(iLoadCase.Split(' ')[1]);
                    var value = _lCasesAndCombos.IndexOf(iLoadCase);
                    _loadDropLastValue = value;
                    _lastLoadCase      = iLoadCase;
                    if (value == -1)
                    {
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, $"{iLoadCase} has no results. Provide valid load case.");
                        return;
                    }
                    if (value < _countCases)
                    {
                        _lcresults = _results.GetResultsInFeNodes(LoadingType.LoadCaseType, no);
                    }
                    else if (value < _countCases + _countCombos)
                    {
                        _lcresults = _results.GetResultsInFeNodes(LoadingType.LoadCombinationType, no);
                    }
                    else if (value < _countCases + _countCombos + _countRcombos)
                    {
                        _lcresults = _results.GetResultsInFeNodes(LoadingType.ResultCombinationType, no);
                    }
                    else
                    {
                        msg.Add("Load case or combo not found");
                        return;
                    }
                    // Get analysis results
                    _resultTypes = new HashSet <ResultsValueType>();
                    outResults   = new RFResults(_lcresults, _saveddata, buttonLocal.Active, ref _resultTypes, iLoadCase,
                                                 _memberForcesCheck.Active, _surfaceForcesCheck.Active, _nodalReactionsCheck.Active,
                                                 _lineReactionsCheck.Active);
                    // Get deformations
                    if (_deformationsCheck.Active)
                    {
                        if (!_deformation_results)
                        {
                            AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Run component again to get deformation results.");
                        }
                        else
                        {
                            _meshdisplacements         = GetMeshDisplacements(ref _sfcNo, ref msg);
                            _memberdisplacements       = GetMemberDisplacements(ref _memberNo, ref msg);
                            _meshdisplacementsByType   = GetMeshDisplacementsByType(result_type);
                            _memberdisplacementsByType = GetMemberDisplacementsByType(result_type);
                        }
                    }
                    // Update drop down menu of result types
                    if (result_type == 0) // if no value obtaines through overwrite
                    {
                        _resultDropLastValue = 0;
                        updateDropDownMenu2(_resultTypes.ToList(), ref result_type);
                    }
                    // Set _resetLC to false again
                    _resetLC         = false;
                    _resetResultType = true;
                }
                if (_resetResultType)     // when there are changes in drop down menu
                {
                    if (result_type == 0) // if no value obtaines through overwrite
                    {
                        result_type = Int32.Parse(_resulttypeDrop.Items[_resulttypeDrop.Value].name);
                    }
                    if (_deformationsCheck.Active)
                    {
                        _meshdisplacementsByType   = GetMeshDisplacementsByType(result_type);
                        _memberdisplacementsByType = GetMemberDisplacementsByType(result_type);
                    }
                    // Get analysis results
                    if (result_type > 0)
                    {
                        outResults.ResultType = ((ResultsValueType)result_type).ToString();
                    }
                    // Set _resetType to false again
                    _resetResultType = false;
                }
                _lastType = result_type;
                // Check results
                if (_meshdisplacements.DataCount > 0 && _meshdisplacementsByType.DataCount == 0)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, $"No surface results found for result type {((ResultsValueType)result_type).ToString()}");
                }
                if (_memberdisplacements.DataCount > 0 && _memberdisplacementsByType.DataCount == 0)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, $"No member results found for result type {((ResultsValueType)result_type).ToString()}");
                }
                // Get output
                _deformedMeshes  = GetDeformedMeshes(scale, ref msg);
                _deformedMembers = GetDeformedMembers(scale, ref msg);

                // Output calculation results
                DA.SetData(0, outResults);

                // Assign GH Output
                DA.SetDataList(1, _deformedMembers);
                DA.SetDataList(2, _memberNo);
                DA.SetDataList(3, _deformedMeshes);
                DA.SetDataList(4, _sfcNo);
            }
            if (msg.Count > 0)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, String.Join(System.Environment.NewLine, msg.ToArray()));
            }
        }
Exemple #2
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object can be used to retrieve data from input parameters and
        /// to store data in output parameters.</param>
        protected override void SolveInstance(IGH_DataAccess DA, EvaluationUnit unit)
        {
            var run = false;

            var ghNodes   = new List <GH_RFEM>();
            var ghLines   = new List <GH_RFEM>();
            var ghMembers = new List <GH_RFEM>();
            var ghSfcs    = new List <GH_RFEM>();
            var ghOps     = new List <GH_RFEM>();
            var ghSupsP   = new List <GH_RFEM>();
            var ghSupsL   = new List <GH_RFEM>();
            var ghSupsS   = new List <GH_RFEM>();
            var ghMHs     = new List <GH_RFEM>();
            var ghLHs     = new List <GH_RFEM>();
            var ghCSs     = new List <GH_RFEM>();
            var ghMats    = new List <GH_RFEM>();

            var ghNodalLoads   = new List <GH_RFEM>();
            var ghLineLoads    = new List <GH_RFEM>();
            var ghMemberLoads  = new List <GH_RFEM>();
            var ghSurfaceLoads = new List <GH_RFEM>();
            var ghPolyLoads    = new List <GH_RFEM>();

            var ghLoadCases    = new List <GH_RFEM>();
            var ghLoadCombos   = new List <GH_RFEM>();
            var ghResultCombos = new List <GH_RFEM>();

            var        modelName = "";
            IModel     model     = null;
            IModelData data      = null;
            ILoads     loads     = null;

            var errorMsg = new List <string>();

            DA.GetData(0, ref run);
            if (run)
            {
                Component_SetData.ClearOutput(ref nodesNo, ref linesNo, ref membersNo, ref srfcNo, ref opNo, ref nodSupNo, ref lineSupNo, ref sfcSupNo,
                                              ref memberHingeNo, ref lineHingeNo, ref croSecNo, ref matNo, ref nodalLoadNo, ref lineLoadNo, ref memberLoadNo, ref surfaceLoadNo,
                                              ref polyLoadNo, ref loadcaseNo, ref loadcomboNo, ref resultcomboNo);
                if (!DA.GetData(modelDataCount3 + 1, ref modelName))
                {
                    Component_GetData.ConnectRFEM(ref model, ref data);
                }
                else
                {
                    Component_GetData.ConnectRFEM(modelName, ref model, ref data);
                }
                try
                {
                    // Set data
                    data.PrepareModification();
                    if (DA.GetDataList(12, ghMats))
                    {
                        data.SetRFMaterials(ghMats, ref matNo, ref errorMsg);
                    }
                    if (DA.GetDataList(11, ghCSs))
                    {
                        data.SetRFCroSecs(ghCSs, ref croSecNo, ref errorMsg);
                    }
                    if (DA.GetDataList(9, ghMHs))
                    {
                        data.SetRFMemberHinges(ghMHs, ref memberHingeNo, ref errorMsg);
                    }
                    if (DA.GetDataList(1, ghNodes))
                    {
                        data.SetRFNodes(ghNodes, ref nodesNo, ref errorMsg);
                    }
                    if (DA.GetDataList(2, ghLines))
                    {
                        data.SetRFLines(ghLines, ref linesNo, ref errorMsg);
                    }
                    if (DA.GetDataList(3, ghMembers))
                    {
                        data.SetRFMembers(ghMembers, ref membersNo, ref errorMsg);
                    }
                    if (DA.GetDataList(4, ghSfcs))
                    {
                        data.SetRFSurfaces(ghSfcs, ref srfcNo, ref errorMsg);
                    }
                    if (DA.GetDataList(5, ghOps))
                    {
                        data.SetRFOpenings(ghOps, ref opNo, ref errorMsg);
                    }
                    if (DA.GetDataList(6, ghSupsP))
                    {
                        data.SetRFSupportsP(ghSupsP, ref nodSupNo, ref errorMsg);
                    }
                    if (DA.GetDataList(7, ghSupsL))
                    {
                        data.SetRFSupportsL(ghSupsL, ref lineSupNo, ref errorMsg);
                    }
                    if (DA.GetDataList(8, ghSupsS))
                    {
                        data.SetRFSupportsS(ghSupsS, ref sfcSupNo, ref errorMsg);
                    }
                    if (DA.GetDataList(10, ghLHs))
                    {
                        data.SetRFLineHinges(ghLHs, ref lineHingeNo, ref errorMsg);
                    }
                    data.FinishModification();
                    // Set Load Cases and Combos
                    if (DA.GetDataList(modelDataCount2 + 1, ghLoadCases))
                    {
                        if (loads == null)
                        {
                            Component_GetData.GetLoadsFromRFEM(model, ref loads);
                        }
                        data.SetRFLoadCases(loads, ghLoadCases, ref loadcaseNo, ref errorMsg);
                    }
                    if (DA.GetDataList(modelDataCount2 + 2, ghLoadCombos))
                    {
                        if (loads == null)
                        {
                            Component_GetData.GetLoadsFromRFEM(model, ref loads);
                        }
                        data.SetRFLoadCombos(loads, ghLoadCombos, ref loadcomboNo, ref errorMsg);
                    }
                    if (DA.GetDataList(modelDataCount2 + 3, ghResultCombos))
                    {
                        if (loads == null)
                        {
                            Component_GetData.GetLoadsFromRFEM(model, ref loads);
                        }
                        data.SetRFResultCombos(loads, ghResultCombos, ref resultcomboNo, ref errorMsg);
                    }
                    // Set Loads
                    if (DA.GetDataList(modelDataCount + 1, ghNodalLoads))
                    {
                        if (loads == null)
                        {
                            Component_GetData.GetLoadsFromRFEM(model, ref loads);
                        }
                        data.SetRFNodalLoads(loads, ghNodalLoads, ref nodalLoadNo, ref errorMsg);
                    }
                    if (DA.GetDataList(modelDataCount + 2, ghLineLoads))
                    {
                        if (loads == null)
                        {
                            Component_GetData.GetLoadsFromRFEM(model, ref loads);
                        }
                        data.SetRFLineLoads(loads, ghLineLoads, ref lineLoadNo, ref errorMsg);
                    }
                    if (DA.GetDataList(modelDataCount + 3, ghMemberLoads))
                    {
                        if (loads == null)
                        {
                            Component_GetData.GetLoadsFromRFEM(model, ref loads);
                        }
                        data.SetRFMemberLoads(loads, ghMemberLoads, ref memberLoadNo, ref errorMsg);
                    }
                    if (DA.GetDataList(modelDataCount + 4, ghSurfaceLoads))
                    {
                        if (loads == null)
                        {
                            Component_GetData.GetLoadsFromRFEM(model, ref loads);
                        }
                        data.SetRFSurfaceLoads(loads, ghSurfaceLoads, ref surfaceLoadNo, ref errorMsg);
                    }
                    if (DA.GetDataList(modelDataCount + 5, ghPolyLoads))
                    {
                        if (loads == null)
                        {
                            Component_GetData.GetLoadsFromRFEM(model, ref loads);
                        }
                        data.SetRFFreePolygonLoads(loads, ghPolyLoads, ref polyLoadNo, ref errorMsg);
                    }
                }
                catch (Exception ex)
                {
                    Component_SetData.ClearOutput(ref nodesNo, ref linesNo, ref membersNo, ref srfcNo, ref opNo, ref nodSupNo, ref lineSupNo, ref sfcSupNo,
                                                  ref memberHingeNo, ref lineHingeNo, ref croSecNo, ref matNo, ref nodalLoadNo, ref lineLoadNo, ref memberLoadNo, ref surfaceLoadNo,
                                                  ref polyLoadNo, ref loadcaseNo, ref loadcomboNo, ref resultcomboNo);
                    Component_GetData.DisconnectRFEM(ref model, ref data);
                    throw ex;
                }
                Component_GetData.DisconnectRFEM(ref model, ref data);
            }
            // Assign Output
            DA.SetDataList(0, nodesNo);
            DA.SetDataList(1, linesNo);
            DA.SetDataList(2, membersNo);
            DA.SetDataList(3, srfcNo);
            DA.SetDataList(4, opNo);
            DA.SetDataList(5, nodSupNo);
            DA.SetDataList(6, lineSupNo);
            DA.SetDataList(7, sfcSupNo);
            DA.SetDataList(8, memberHingeNo);
            DA.SetDataList(9, lineHingeNo);
            DA.SetDataList(10, croSecNo);
            DA.SetDataList(11, matNo);
            DA.SetDataList(12, nodalLoadNo);
            DA.SetDataList(13, lineLoadNo);
            DA.SetDataList(14, memberLoadNo);
            DA.SetDataList(15, surfaceLoadNo);
            DA.SetDataList(16, polyLoadNo);
            DA.SetDataList(17, loadcaseNo);
            DA.SetDataList(18, loadcomboNo);
            DA.SetDataList(19, resultcomboNo);

            if (errorMsg.Count != 0)
            {
                //errorMsg.Add("List item index may be one unit lower than object number");
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, String.Join(System.Environment.NewLine, errorMsg.ToArray()));
            }
        }
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object can be used to retrieve data from input parameters and
        /// to store data in output parameters.</param>
        protected override void SolveInstance(IGH_DataAccess DA, EvaluationUnit unit)
        {
            // Input counter
            modelDataCount1 = 1 + modelDataCount2;

            // RFEM variables
            var        modelName = "";
            IModel     model     = null;
            IModelData data      = null;
            ILoads     loads     = null;

            // Output message
            var msg = new List <string>();

            // Assign GH Input
            bool getnodes        = false;
            bool getlines        = false;
            bool getmembers      = false;
            bool getsurfaces     = false;
            bool getopenings     = false;
            bool getsupportsP    = false;
            bool getsupportsL    = false;
            bool getsupportsS    = false;
            bool getMemberHinges = false;
            bool getLineHinges   = false;
            bool getCroSecs      = false;
            bool getMaterials    = false;
            bool getNodalLoads   = false;
            bool getLineLoads    = false;
            bool getMemberLoads  = false;
            bool getSurfaceLoads = false;
            bool getPolyLoads    = false;
            bool getLoadCases    = false;
            bool getLoadCombos   = false;
            bool getResultCombos = false;
            bool run             = false;
            var  ghFilters       = new List <GH_RFFilter>();
            var  inFilters       = new List <RFFilter>();

            DA.GetData(0, ref run);
            DA.GetData(1, ref getnodes);
            DA.GetData(2, ref getlines);
            DA.GetData(3, ref getmembers);
            DA.GetData(4, ref getsurfaces);
            DA.GetData(5, ref getopenings);
            DA.GetData(6, ref getsupportsP);
            DA.GetData(7, ref getsupportsL);
            DA.GetData(8, ref getsupportsS);
            DA.GetData(9, ref getMemberHinges);
            DA.GetData(10, ref getLineHinges);
            DA.GetData(11, ref getCroSecs);
            DA.GetData(12, ref getMaterials);
            DA.GetData(13, ref getNodalLoads);
            DA.GetData(14, ref getLineLoads);
            DA.GetData(15, ref getMemberLoads);
            DA.GetData(16, ref getSurfaceLoads);
            DA.GetData(17, ref getPolyLoads);
            DA.GetData(18, ref getLoadCases);
            DA.GetData(19, ref getLoadCombos);
            DA.GetData(20, ref getResultCombos);
            if (DA.GetDataList(modelDataCount3 + 1, ghFilters))
            {
                inFilters = ghFilters.Select(x => x.Value).ToList();
            }

            // Do stuff
            if (run)
            {
                if (!DA.GetData(modelDataCount3 + 2, ref modelName))
                {
                    Component_GetData.ConnectRFEM(ref model, ref data);
                }
                else
                {
                    Component_GetData.ConnectRFEM(modelName, ref model, ref data);
                }
                Component_GetData.ClearOutput(ref rfNodes, ref rfLines, ref rfMembers, ref rfSurfaces, ref rfOpenings,
                                              ref rfSupportsP, ref rfSupportsL, ref rfSupportsS, ref rfLineHinges, ref rfCroSecs, ref rfMaterials, ref rfNodalLoads,
                                              ref rfLineLoads, ref rfMemberLoads, ref rfSurfaceLoads, ref rfPolyLoads, ref rfLoadCases, ref rfLoadCombos,
                                              ref rfResultCombos, ref rfMemberHinges);

                try
                {
                    if (getnodes)
                    {
                        var filNodes = Component_GetData.FilterNodes(data, inFilters);
                        rfNodes = Component_GetData.GetRFNodes(filNodes, data);
                    }
                    if (getlines)
                    {
                        var filLines = Component_GetData.FilterLines(data, inFilters);
                        rfLines = Component_GetData.GetRFLines(filLines, data);
                    }
                    if (getmembers)
                    {
                        var filMembers = Component_GetData.FilterMembers(data, inFilters);
                        rfMembers = Component_GetData.GetRFMembers(filMembers, data);
                    }
                    if (getsurfaces)
                    {
                        var filSrfcs = Component_GetData.FilterSurfaces(data, inFilters);
                        rfSurfaces = Component_GetData.GetRFSurfaces(filSrfcs, data);
                    }
                    if (getopenings)
                    {
                        var filOpenings = Component_GetData.FilterOpenings(data, inFilters);
                        rfOpenings = Component_GetData.GetRFOpenings(filOpenings, data);
                    }
                    if (getsupportsP)
                    {
                        var filSupportsP = Component_GetData.FilterSupsP(data, inFilters);
                        rfSupportsP = Component_GetData.GetRFSupportsP(filSupportsP, data);
                    }
                    if (getsupportsL)
                    {
                        var filSupportsL = Component_GetData.FilterSupsL(data, inFilters);
                        rfSupportsL = Component_GetData.GetRFSupportsL(filSupportsL, data);
                    }
                    if (getsupportsS)
                    {
                        var filSupportsS = Component_GetData.FilterSupsS(data, inFilters);
                        rfSupportsS = Component_GetData.GetRFSupportsS(filSupportsS, data);
                    }
                    if (getMemberHinges)
                    {
                        var filMemberHinges = Component_GetData.FilterMH(data, inFilters);
                        rfMemberHinges = Component_GetData.GetRFMemberHinges(filMemberHinges, data);
                    }
                    if (getLineHinges)
                    {
                        var filLineHinges = Component_GetData.FilterLH(data, inFilters);
                        rfLineHinges = Component_GetData.GetRFLineHinges(filLineHinges, data);
                    }
                    if (getCroSecs)
                    {
                        var filCroSecs = Component_GetData.FilterCroSecs(data, inFilters);
                        rfCroSecs = Component_GetData.GetRFCroSecs(filCroSecs, model, ref msg);
                    }
                    if (getMaterials)
                    {
                        var filMaterials = Component_GetData.FilterMaterials(data, inFilters);
                        rfMaterials = Component_GetData.GetRFMaterials(filMaterials, data);
                    }
                    //Get Loads?
                    if (getNodalLoads || getLineLoads || getMemberLoads || getSurfaceLoads || getPolyLoads ||
                        getLoadCases || getLoadCombos || getResultCombos)
                    {
                        Component_GetData.GetLoadsFromRFEM(model, ref loads);
                    }
                    if (getNodalLoads)
                    {
                        var filNodalLoads = Component_GetData.FilterNodalLoads(data, loads, inFilters);
                        rfNodalLoads = Component_GetData.GetRFNodalLoads(filNodalLoads, data);
                    }
                    if (getLineLoads)
                    {
                        var filLineLoads = Component_GetData.FilterLineLoads(data, loads, inFilters);
                        rfLineLoads = Component_GetData.GetRFLineLoads(filLineLoads, data);
                    }
                    if (getMemberLoads)
                    {
                        var filMemberLoads = Component_GetData.FilterMemberLoads(data, loads, inFilters);
                        rfMemberLoads = Component_GetData.GetRFMemberLoads(filMemberLoads, data);
                    }
                    if (getSurfaceLoads)
                    {
                        var filSurfaceLoads = Component_GetData.FilterSurfaceLoads(data, loads, inFilters);
                        rfSurfaceLoads = Component_GetData.GetRFSurfaceLoads(filSurfaceLoads, data);
                    }
                    if (getPolyLoads)
                    {
                        var filPolyLoads = Component_GetData.FilterPolyLoads(data, loads, inFilters);
                        rfPolyLoads = Component_GetData.GetRFPolyLoads(filPolyLoads, data);
                    }
                    if (getLoadCases)
                    {
                        var filLoadCases = Component_GetData.FilterLoadCases(data, loads, inFilters);
                        rfLoadCases = Component_GetData.GetRFLoadCases(filLoadCases, data);
                    }
                    if (getLoadCombos)
                    {
                        var filLoadCombos = Component_GetData.FilterLoadCombos(data, loads, inFilters);
                        rfLoadCombos = Component_GetData.GetRFLoadCombos(filLoadCombos, data);
                    }
                    if (getResultCombos)
                    {
                        var filResultombos = Component_GetData.FilterResultCombos(data, loads, inFilters);
                        rfResultCombos = Component_GetData.GetRFResultCombos(filResultombos, data);
                    }
                }
                catch (Exception ex)
                {
                    Component_GetData.ClearOutput(ref rfNodes, ref rfLines, ref rfMembers, ref rfSurfaces, ref rfOpenings,
                                                  ref rfSupportsP, ref rfSupportsL, ref rfSupportsS, ref rfLineHinges, ref rfCroSecs, ref rfMaterials, ref rfNodalLoads,
                                                  ref rfLineLoads, ref rfMemberLoads, ref rfSurfaceLoads, ref rfPolyLoads, ref rfLoadCases, ref rfLoadCombos,
                                                  ref rfResultCombos, ref rfMemberHinges);
                    throw ex;
                }
                Component_GetData.DisconnectRFEM(ref model, ref data);
            }

            // Assign GH Output
            DA.SetDataList(0, rfNodes);
            DA.SetDataList(1, rfLines);
            DA.SetDataList(2, rfMembers);
            DA.SetDataList(3, rfSurfaces);
            DA.SetDataList(4, rfOpenings);
            DA.SetDataList(5, rfSupportsP);
            DA.SetDataList(6, rfSupportsL);
            DA.SetDataList(7, rfSupportsS);
            DA.SetDataList(8, rfMemberHinges);
            DA.SetDataList(9, rfLineHinges);
            DA.SetDataList(10, rfCroSecs);
            DA.SetDataList(11, rfMaterials);
            DA.SetDataList(12, rfNodalLoads);
            DA.SetDataList(13, rfLineLoads);
            DA.SetDataList(14, rfMemberLoads);
            DA.SetDataList(15, rfSurfaceLoads);
            DA.SetDataList(16, rfPolyLoads);
            DA.SetDataList(17, rfLoadCases);
            DA.SetDataList(18, rfLoadCombos);
            DA.SetDataList(19, rfResultCombos);

            if (msg.Count != 0)
            {
                //errorMsg.Add("List item index may be one unit lower than object number");
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, String.Join(System.Environment.NewLine, msg.ToArray()));
            }
        }
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object can be used to retrieve data from input parameters and
        /// to store data in output parameters.</param>
        protected override void SolveInstance(IGH_DataAccess DA, EvaluationUnit unit)
        {
            var run = false;

            var ghNodes   = new List <GH_RFEM>();
            var ghLines   = new List <GH_RFEM>();
            var ghMembers = new List <GH_RFEM>();
            var ghSfcs    = new List <GH_RFEM>();
            var ghOps     = new List <GH_RFEM>();
            var ghSupsP   = new List <GH_RFEM>();
            var ghSupsL   = new List <GH_RFEM>();
            var ghLHs     = new List <GH_RFEM>();
            var ghCSs     = new List <GH_RFEM>();
            var ghMats    = new List <GH_RFEM>();

            var ghNodalLoads = new List <GH_RFEM>();

            var        modelName = "";
            IModel     model     = null;
            IModelData data      = null;
            ILoads     loads     = null;

            DA.GetData(modelDataCount - 1, ref run);
            if (run)
            {
                Component_SetData.ClearOutput(ref nodesNo, ref linesNo, ref membersNo, ref srfcNo, ref opNo, ref nodSupNo, ref lineSupNo,
                                              ref lineHingeNo, ref croSecNo, ref matNo, ref nodalLoadNo);
                if (!DA.GetData(modelDataCount + modelDataCount2, ref modelName))
                {
                    Component_GetData.ConnectRFEM(ref model, ref data);
                }
                else
                {
                    Component_GetData.ConnectRFEM(modelName, ref model, ref data);
                }
                try
                {
                    // Set data
                    data.PrepareModification();
                    if (DA.GetDataList(9, ghMats))
                    {
                        data.SetRFMaterials(ghMats, ref matNo);
                    }
                    if (DA.GetDataList(8, ghCSs))
                    {
                        data.SetRFCroSecs(ghCSs, ref croSecNo);
                    }
                    if (DA.GetDataList(0, ghNodes))
                    {
                        data.SetRFNodes(ghNodes, ref nodesNo);
                    }
                    if (DA.GetDataList(1, ghLines))
                    {
                        data.SetRFLines(ghLines, ref linesNo);
                    }
                    if (DA.GetDataList(2, ghMembers))
                    {
                        data.SetRFMembers(ghMembers, ref membersNo);
                    }
                    if (DA.GetDataList(3, ghSfcs))
                    {
                        data.SetRFSurfaces(ghSfcs, ref srfcNo);
                    }
                    if (DA.GetDataList(4, ghOps))
                    {
                        data.SetRFOpenings(ghOps, ref opNo);
                    }
                    if (DA.GetDataList(5, ghSupsP))
                    {
                        data.SetRFSupportsP(ghSupsP, ref nodSupNo);
                    }
                    if (DA.GetDataList(6, ghSupsL))
                    {
                        data.SetRFSupportsL(ghSupsL, ref lineSupNo);
                    }
                    if (DA.GetDataList(7, ghLHs))
                    {
                        data.SetRFLineHinges(ghLHs, ref lineHingeNo);
                    }
                    data.FinishModification();
                    // Set Loads
                    if (DA.GetDataList(modelDataCount, ghNodalLoads))
                    {
                        Component_GetData.GetLoadsFromRFEM(model, ref loads);
                        data.SetRFNodalLoads(loads, ghNodalLoads, ref nodalLoadNo);
                    }
                }
                catch (Exception ex)
                {
                    Component_SetData.ClearOutput(ref nodesNo, ref linesNo, ref membersNo, ref srfcNo, ref opNo, ref nodSupNo, ref lineSupNo,
                                                  ref lineHingeNo, ref croSecNo, ref matNo, ref nodalLoadNo);
                    Component_GetData.DisconnectRFEM(ref model, ref data);
                    throw ex;
                }
                Component_GetData.DisconnectRFEM(ref model, ref data);
            }
            // Assign Output
            DA.SetDataList(0, nodesNo);
            DA.SetDataList(1, linesNo);
            DA.SetDataList(2, membersNo);
            DA.SetDataList(3, srfcNo);
            DA.SetDataList(4, opNo);
            DA.SetDataList(5, nodSupNo);
            DA.SetDataList(6, lineSupNo);
            DA.SetDataList(7, lineHingeNo);
            DA.SetDataList(8, croSecNo);
            DA.SetDataList(9, matNo);
            DA.SetDataList(10, nodalLoadNo);
        }
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object can be used to retrieve data from input parameters and
        /// to store data in output parameters.</param>
        protected override void SolveInstance(IGH_DataAccess DA, EvaluationUnit unit)
        {
            // Input counter
            modelDataCount1 = modelDataCount + modelDataCount2;

            // RFEM variables
            var        modelName = "";
            IModel     model     = null;
            IModelData data      = null;
            ILoads     loads     = null;

            // Assign GH Input
            bool getnodes      = false;
            bool getlines      = false;
            bool getmembers    = false;
            bool getsurfaces   = false;
            bool getopenings   = false;
            bool getsupportsP  = false;
            bool getsupportsL  = false;
            bool getLineHinges = false;
            bool getCroSecs    = false;
            bool getMaterials  = false;
            bool getNodalLoads = false;
            bool run           = false;
            var  ghFilters     = new List <GH_RFFilter>();
            var  inFilters     = new List <RFFilter>();

            DA.GetData(0, ref getnodes);
            DA.GetData(1, ref getlines);
            DA.GetData(2, ref getmembers);
            DA.GetData(3, ref getsurfaces);
            DA.GetData(4, ref getopenings);
            DA.GetData(5, ref getsupportsP);
            DA.GetData(6, ref getsupportsL);
            DA.GetData(7, ref getLineHinges);
            DA.GetData(8, ref getCroSecs);
            DA.GetData(9, ref getMaterials);
            DA.GetData(10, ref run);
            DA.GetData(11, ref getNodalLoads);
            if (DA.GetDataList(modelDataCount1, ghFilters))
            {
                inFilters = ghFilters.Select(x => x.Value).ToList();
            }

            // Do stuff
            if (run)
            {
                if (!DA.GetData(modelDataCount1 + 1, ref modelName))
                {
                    Component_GetData.ConnectRFEM(ref model, ref data);
                }
                else
                {
                    Component_GetData.ConnectRFEM(modelName, ref model, ref data);
                }
                Component_GetData.ClearOutput(ref rfNodes, ref rfLines, ref rfMembers, ref rfSurfaces, ref rfOpenings,
                                              ref rfSupportsP, ref rfSupportsL, ref rfLineHinges, ref rfCroSecs, ref rfMaterials, ref rfNodalLoads);

                try
                {
                    if (getnodes)
                    {
                        var filNodes = Component_GetData.FilterNodes(data, inFilters);
                        rfNodes = Component_GetData.GetRFNodes(filNodes, data);
                    }
                    if (getlines)
                    {
                        var filLines = Component_GetData.FilterLines(data, inFilters);
                        rfLines = Component_GetData.GetRFLines(filLines, data);
                    }
                    if (getmembers)
                    {
                        var filMembers = Component_GetData.FilterMembers(data, inFilters);
                        rfMembers = Component_GetData.GetRFMembers(filMembers, data);
                    }
                    if (getsurfaces)
                    {
                        var filSrfcs = Component_GetData.FilterSurfaces(data, inFilters);
                        rfSurfaces = Component_GetData.GetRFSurfaces(filSrfcs, data);
                    }
                    if (getopenings)
                    {
                        var filOpenings = Component_GetData.FilterOpenings(data, inFilters);
                        rfOpenings = Component_GetData.GetRFOpenings(filOpenings, data);
                    }
                    if (getsupportsP)
                    {
                        var filSupportsP = Component_GetData.FilterSupsP(data, inFilters);
                        rfSupportsP = Component_GetData.GetRFSupportsP(filSupportsP, data);
                    }
                    if (getsupportsL)
                    {
                        var filSupportsL = Component_GetData.FilterSupsL(data, inFilters);
                        rfSupportsL = Component_GetData.GetRFSupportsL(filSupportsL, data);
                    }
                    if (getLineHinges)
                    {
                        var filLineHinges = Component_GetData.FilterLH(data, inFilters);
                        rfLineHinges = Component_GetData.GetRFLineHinges(filLineHinges, data);
                    }
                    if (getCroSecs)
                    {
                        var filCroSecs = Component_GetData.FilterCroSecs(data, inFilters);
                        rfCroSecs = Component_GetData.GetRFCroSecs(filCroSecs, data);
                    }
                    if (getMaterials)
                    {
                        var filMaterials = Component_GetData.FilterMaterials(data, inFilters);
                        rfMaterials = Component_GetData.GetRFMaterials(filMaterials, data);
                    }
                    //Get Loads?
                    if (getNodalLoads)
                    {
                        Component_GetData.GetLoadsFromRFEM(model, ref loads);
                    }
                    if (getNodalLoads)
                    {
                        var filNodalLoads = Component_GetData.FilterNodalLoads(data, loads, inFilters);
                        rfNodalLoads = Component_GetData.GetRFNodalLoads(filNodalLoads, data);
                    }
                }
                catch (Exception ex)
                {
                    Component_GetData.ClearOutput(ref rfNodes, ref rfLines, ref rfMembers, ref rfSurfaces, ref rfOpenings,
                                                  ref rfSupportsP, ref rfSupportsL, ref rfLineHinges, ref rfCroSecs, ref rfMaterials, ref rfNodalLoads);
                    throw ex;
                }
                Component_GetData.DisconnectRFEM(ref model, ref data);
            }

            // Assign GH Output
            DA.SetDataList(0, rfNodes);
            DA.SetDataList(1, rfLines);
            DA.SetDataList(2, rfMembers);
            DA.SetDataList(3, rfSurfaces);
            DA.SetDataList(4, rfOpenings);
            DA.SetDataList(5, rfSupportsP);
            DA.SetDataList(6, rfSupportsL);
            DA.SetDataList(7, rfLineHinges);
            DA.SetDataList(8, rfCroSecs);
            DA.SetDataList(9, rfMaterials);
            DA.SetDataList(10, rfNodalLoads);
        }
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object can be used to retrieve data from input parameters and
        /// to store data in output parameters.</param>
        protected override void SolveInstance(IGH_DataAccess DA, EvaluationUnit unit)
        {
            //OnComponentLoaded();

            // Input counter
            //modelDataCount1 = 1 + modelDataCount2;

            // RFEM variables
            var        modelName = "";
            IModel     model     = null;
            IModelData data      = null;
            ILoads     loads     = null;

            // Output message
            var msg = new List <string>();

            // Assign GH Input
            bool run   = false;
            var  scale = 0.0;

            DA.GetData(0, ref run);
            DA.GetData(1, ref scale);

            // Do stuff
            if (run)
            {
                if (!DA.GetData(3, ref modelName))
                {
                    Component_GetData.ConnectRFEM(ref model, ref data);
                }
                else
                {
                    Component_GetData.ConnectRFEM(modelName, ref model, ref data);
                }
                _saveddata = data;
                try
                {
                    // Get deformtions
                    _resetLC = true;
                    // Get loads
                    Component_GetData.GetLoadsFromRFEM(model, ref loads);
                    // Get calculation results
                    _results = model.GetCalculation();
                    var errors = _results.CalculateAll();
                    if (errors != null)
                    {
                        msg.AddRange(errors.Select(x => x.Description));
                    }
                    // Update load cases and combos to display in dropdown menu
                    loads.GetLoadCasesAndCombos(ref _lCasesAndCombos, ref _countCases, ref _countCombos, ref _countRcombos);
                    updateDropDownMenu(_lCasesAndCombos);
                    // Get Fe Meshes from RFEM
                    _rfemMesh = _results.GetFeMesh();
                    _feMeshes = CreateFEMeshes(ref msg);
                    // _controlPoints = CreateControlPoints(ref msg); -> Obtained with displacements
                }
                catch (Exception ex)
                {
                    // Clear output!!!
                    _saveddata = null;
                    _rfemMesh  = null;
                    _results   = null;
                    _lcresults = null;
                    _feMeshes.Clear();
                    _meshdisplacements.Clear();
                    _deformedMeshes.Clear();
                    _controlPoints.Clear();
                    _memberdisplacements.Clear();
                    _deformedMembers.Clear();
                    throw ex;
                }
                Component_GetData.DisconnectRFEM(ref model, ref data);
            }
            // Get results to display
            if (_loadDrop.Items.Count > 0 && _resetLC && msg.Count == 0)
            {
                int no = Int16.Parse(_loadDrop.Items[_loadDrop.Value].name.Split(' ')[1]);
                if (_loadDrop.Value < _countCases)
                {
                    _lcresults = _results.GetResultsInFeNodes(LoadingType.LoadCaseType, no);
                }
                else if (_loadDrop.Value < _countCases + _countCombos)
                {
                    _lcresults = _results.GetResultsInFeNodes(LoadingType.LoadCombinationType, no);
                }
                else if (_loadDrop.Value < _countCases + _countCombos + _countRcombos)
                {
                    _lcresults = _results.GetResultsInFeNodes(LoadingType.ResultCombinationType, no);
                }
                else
                {
                    msg.Add("Load case or combo not found");
                }
                // Get deformations
                _meshdisplacements   = GetMeshDisplacements(ref msg);
                _memberdisplacements = GetMemberDisplacements(ref msg);
                // Set _resetLC to false again
                _resetLC = false;
            }

            // Get output
            _deformedMeshes  = GetDeformedMeshes(scale, ref msg);
            _deformedMembers = GetDeformedMembers(scale, ref msg);

            // Assign GH Output
            DA.SetDataTree(0, _deformedMembers);
            DA.SetDataTree(1, _deformedMeshes);

            if (msg.Count != 0)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, String.Join(System.Environment.NewLine, msg.ToArray()));
            }
        }
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object can be used to retrieve data from input parameters and
        /// to store data in output parameters.</param>
        protected override void SolveInstance(IGH_DataAccess DA, EvaluationUnit unit)
        {
            var run = false;

            var combos = new List <int>();
            var mass   = 0.0;


            var        modelName = "";
            IModel     model     = null;
            IModelData data      = null;

            var errorMsg = new List <string>();

            DA.GetData(1, ref run);
            if (run)
            {
                if (!DA.GetData(2 + 1, ref modelName))
                {
                    Component_GetData.ConnectRFEM(ref model, ref data);
                }
                else
                {
                    Component_GetData.ConnectRFEM(modelName, ref model, ref data);
                }
                try
                {
                    //Calculate Load Combos
                    DA.GetDataList(0, combos);
                    var myCalculation = model.GetCalculation();
                    myCalculation.Clean();
                    foreach (var no in combos)
                    {
                        ErrorInfo[] errormsg = myCalculation.Calculate(LoadingType.LoadCombinationType, 1);
                    }

                    // Get EC3 LoadCase
                    var myEC3 = (Dlubal.STEEL_EC3.Module)model.GetModule("STEEL_EC3");
                    Dlubal.STEEL_EC3.ICase myCaseEC3 = myEC3.moGetCase(1, ITEM_AT.AT_NO);

                    // Get Cross Sections
                    // Select cross sections?
                    var countCS = myCaseEC3.moGetCrossSectionsCount();
                    for (int i = 0; i < countCS; i++)
                    {
                        Dlubal.STEEL_EC3.CROSS_SECTION myCSEC3 = myCaseEC3.moGetCrossSection(i + 1, ITEM_AT.AT_NO);
                        myCSEC3.Optimization = 1;
                        myCaseEC3.moSetCrossSection(myCSEC3.No, ITEM_AT.AT_NO, myCSEC3);
                    }

                    // Berechnung durchführen
                    var error = myCaseEC3.moCalculate();

                    //Querschnitt an RFEM übergeben.
                    var myCSECRFEM = new List <CrossSection>();
                    for (int i = 0; i < countCS; i++)
                    {
                        Dlubal.STEEL_EC3.CROSS_SECTION myCSEC3 = myCaseEC3.moGetCrossSection(i + 1, ITEM_AT.AT_NO);
                        var myCS = data.GetCrossSection(i + 1, ItemAt.AtNo).GetData();
                        myCS.TextID      = myCSEC3.Description;
                        myCS.Description = myCSEC3.Description;
                        myCSECRFEM.Add(myCS);
                    }

                    // Set Data
                    data.PrepareModification();
                    foreach (var crosec in myCSECRFEM)
                    {
                        data.SetCrossSection(crosec);
                    }
                    data.FinishModification();

                    // Get steel mass
                    var members = data.GetMembers();
                    mass = members.Sum(item => item.Weight);
                }
                catch (Exception ex)
                {
                    Component_GetData.DisconnectRFEM(ref model, ref data);
                    throw ex;
                }
                Component_GetData.DisconnectRFEM(ref model, ref data);
            }
            // Assign Output
            DA.SetData(0, mass);


            if (errorMsg.Count != 0)
            {
                //errorMsg.Add("List item index may be one unit lower than object number");
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, String.Join(System.Environment.NewLine, errorMsg.ToArray()));
            }
        }
Exemple #8
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object can be used to retrieve data from input parameters and
        /// to store data in output parameters.</param>
        protected override void SolveInstance(IGH_DataAccess DA, EvaluationUnit unit)
        {
            // RFEM variables
            var          modelName = "";
            IModel       model     = null;
            IModelData   data      = null;
            ILoads       loads     = null;
            ICalculation results   = null;

            // Output message
            var msg = new List <string>();

            // Assign GH Input
            bool run     = false;
            var  iLcases = new List <string>();

            DA.GetData(0, ref run);

            // Do stuff
            if (run)
            {
                if (!DA.GetData(3, ref modelName))
                {
                    Component_GetData.ConnectRFEM(ref model, ref data);
                }
                else
                {
                    Component_GetData.ConnectRFEM(modelName, ref model, ref data);
                }
                try
                {
                    // Get loads
                    Component_GetData.GetLoadsFromRFEM(model, ref loads);
                    // Get calculation
                    results = model.GetCalculation();
                    // Update results
                    _maxDisplacements   = new List <Vector3d>();
                    _loadCasesAndCombos = new List <string>();
                    // Get load cases and combos
                    if (!DA.GetDataList(1, iLcases))
                    {
                        var errors = results.CalculateApp();
                        if (errors != null)
                        {
                            msg.AddRange(errors.Select(x => x.Description));
                        }
                        _loadCasesAndCombos = loads.GetLoadCasesAndCombos(0, 0, 0);
                    }
                    else
                    {
                        _loadCasesAndCombos = iLcases;
                    }
                    // Get results
                    foreach (var lc in _loadCasesAndCombos)
                    {
                        Vector3d displacement = new Vector3d(0, 0, 0);
                        Component_GetResults.GetResults(ref results, lc, ref displacement, ref msg);
                        _maxDisplacements.Add(displacement);
                    }
                }
                catch (Exception ex)
                {
                    // Clear output!!!
                    results             = null;
                    _maxDisplacements   = null;
                    _loadCasesAndCombos = null;
                    Component_GetData.DisconnectRFEM(ref model, ref data);
                    throw ex;
                }
                Component_GetData.DisconnectRFEM(ref model, ref data);
            }
            if (msg.Count > 0)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, String.Join(System.Environment.NewLine, msg.ToArray()));
            }
            {
                DA.SetDataList(0, _loadCasesAndCombos);
                DA.SetDataList(1, _maxDisplacements);
            }
        }
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object can be used to retrieve data from input parameters and
        /// to store data in output parameters.</param>
        protected override void SolveInstance(IGH_DataAccess DA, EvaluationUnit unit)
        {
            // RFEM variables
            var        modelName = "";
            IModel     model     = null;
            IModelData data      = null;

            //Additional variables
            var dicMat  = new Dictionary <int, Material>();
            var dicMass = new Dictionary <int, List <double> >();
            var dicVol  = new Dictionary <int, List <double> >();
            var dicGeo  = new Dictionary <int, List <Brep> >();

            // Input
            var msg  = "";
            var msgs = new List <string>();
            var run  = false;

            DA.GetData(0, ref run);


            if (run)
            {
                if (!DA.GetData(1, ref modelName))
                {
                    Component_GetData.ConnectRFEM(ref model, ref data);
                }
                else
                {
                    Component_GetData.ConnectRFEM(modelName, ref model, ref data);
                }
                _materials.Clear();
                _massTree.Clear();
                _volumeTree.Clear();
                _brepTree.Clear();
                try
                {
                    // Get Surfaces
                    var sfcs = Component_GetData.GetRFSurfaces(data.GetSurfaces().ToList(), data);
                    foreach (var sfc in sfcs)
                    {
                        // Add material to dictionary
                        if (!dicMat.ContainsKey(sfc.MaterialNo))
                        {
                            dicMat.Add(sfc.MaterialNo, data.GetMaterial(sfc.MaterialNo, ItemAt.AtNo).GetData());
                            dicMass.Add(sfc.MaterialNo, new List <double>());
                            dicVol.Add(sfc.MaterialNo, new List <double>());
                            dicGeo.Add(sfc.MaterialNo, new List <Brep>());
                        }
                        // Add mass to output list
                        dicVol[sfc.MaterialNo].Add(sfc.Area * sfc.Thickness);
                        dicMass[sfc.MaterialNo].Add(sfc.Area * sfc.Thickness * dicMat[sfc.MaterialNo].SpecificWeight / 10.0);

                        // Add Geometry to output list
                        dicGeo[sfc.MaterialNo].Add(sfc.ToBrep());
                    }
                    // Get Members
                    var members    = Component_GetData.GetRFMembers(data.GetMembers().ToList(), data);
                    var crosecs    = Component_GetData.GetRFCroSecs(data.GetCrossSections().ToList(), model, ref msgs);
                    var cs_indeces = crosecs.Select(x => x.No).ToList();
                    foreach (var member in members)
                    {
                        var mat_index = crosecs.Where(x => x.No == member.StartCrossSectionNo).ToList()[0].MatNo;


                        // Add material to dictionary
                        if (!dicMat.ContainsKey(mat_index))
                        {
                            dicMat.Add(mat_index, data.GetMaterial(mat_index, ItemAt.AtNo).GetData());
                            dicMass.Add(mat_index, new List <double>());
                            dicVol.Add(mat_index, new List <double>());
                            dicGeo.Add(mat_index, new List <Brep>());
                        }

                        // Add mass to output list
                        if (member.EndCrossSectionNo == 0) // In case of tension members, etc.
                        {
                            member.EndCrossSectionNo = member.StartCrossSectionNo;
                        }
                        if (!(cs_indeces.Contains(member.StartCrossSectionNo)) || (!(cs_indeces.Contains(member.EndCrossSectionNo))))
                        {
                            AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, $"Provide cross sections for member No {member.No}.");
                            continue;
                        }
                        var startCroSec = crosecs[cs_indeces.IndexOf(member.StartCrossSectionNo)];
                        var endCroSec   = crosecs[cs_indeces.IndexOf(member.EndCrossSectionNo)];
                        var volume      = (startCroSec.A + endCroSec.A) / 2 * member.Length;
                        dicVol[mat_index].Add(volume);
                        dicMass[mat_index].Add(member.Weight);

                        // Add Geometry to output list
                        var memberShape = Component_ExtrudeMembers.ExtrudeMembersToBrep(member, crosecs, member.Length / 8.0, out msg);
                        if (memberShape == null)
                        {
                            dicGeo[mat_index].Add(null);
                        }
                        else
                        {
                            dicGeo[mat_index].Add(memberShape[0]);
                        }
                    }
                    // Prepare Output
                    var matSorted = dicMat.Values.OrderBy(x => x.No).ToList();
                    _materials = matSorted.Select(x => x.Description).ToList();
                    for (int i = 0; i < matSorted.Count; i++)
                    {
                        var path = new GH_Path(i);
                        _volumeTree.EnsurePath(path);
                        _volumeTree.Branch(path).AddRange(dicVol[matSorted[i].No]);
                        _massTree.EnsurePath(path);
                        _massTree.Branch(path).AddRange(dicMass[matSorted[i].No]);
                        _brepTree.EnsurePath(path);
                        _brepTree.Branch(path).AddRange(dicGeo[matSorted[i].No]);
                    }
                }
                catch (Exception ex)
                {
                    Component_GetData.DisconnectRFEM(ref model, ref data);
                    _materials.Clear();
                    _massTree.Clear();
                    _volumeTree.Clear();
                    _brepTree.Clear();
                    throw ex;
                }
                Component_GetData.DisconnectRFEM(ref model, ref data);
                if (msgs.Count > 0)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, String.Join(System.Environment.NewLine, msg.ToArray()));
                }
                if (msg != "")
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, msg);
                }
            }
            DA.SetDataList(0, _materials);
            DA.SetDataTree(1, _brepTree);
            DA.SetDataTree(2, _massTree);
            DA.SetDataTree(3, _volumeTree);
        }