public async Task QueryResultsAndNodeCoord(string plates,
                                                   IProgress <ProgressModelObject <double> > progress,
                                                   CancellationToken ct)
        {
            IRobotResultQueryReturnType Res;

            var selecPlate = str.Selections.Create(IRobotObjectType.I_OT_PANEL);

            selecPlate.FromText(plates);

            RobotResultQueryParams parm = new RobotResultQueryParams();

            parm.Selection.Set(IRobotObjectType.I_OT_PANEL, selecPlate);

            parm.SetParam(IRobotResultParamType.I_RPT_ELEMENT, 11);
            parm.SetParam(IRobotResultParamType.I_RPT_NODE, 3);
            parm.SetParam(IRobotResultParamType.I_RPT_PANEL, 2);
            parm.SetParam(IRobotResultParamType.I_RPT_RESULT_POINT_COORDINATES, 31);

            parm.ResultIds.SetSize(8);

            parm.ResultIds.Set(1, (int)T_DATA_TYPES.T_FERA_NOD_LONG_UP);
            parm.ResultIds.Set(2, (int)T_DATA_TYPES.T_FERA_NOD_TRAN_UP);
            parm.ResultIds.Set(3, (int)T_DATA_TYPES.T_FERA_NOD_LONG_DOWN);
            parm.ResultIds.Set(4, (int)T_DATA_TYPES.T_FERA_NOD_TRAN_DOWN);
            parm.ResultIds.Set(5, (int)T_DATA_TYPES.T_NODE_COORD_CART_X);
            parm.ResultIds.Set(6, (int)T_DATA_TYPES.T_NODE_COORD_CART_Y);
            parm.ResultIds.Set(7, (int)T_DATA_TYPES.T_NODE_COORD_CART_Z);


            var t = new RSATableQueryingResult();

            Panel = await t.ReadFromTableAsync(plates.ToIntArrayFromRobotStringSelection(), progress, ct);

            if (Panel.Count == 0)
            {
                throw new SlabNotCalculatedExpetation("None of selected slabs are meshed and calculated");
            }


            RobotResultRowSet RobResRowSet = new RobotResultRowSet();

            Res = robot.Project.Structure.Results.Query(parm, RobResRowSet);
            bool ok;
            int  i = 0;

            ok = RobResRowSet.MoveFirst();

            progress.Report(new ProgressModelObject <double>
            {
                ProgressToString = "Getting reinforcements and node coordinations", Progress = 9 * 10
            });


            while (ok)
            {
                ///geting slab number
                int p = (int)RobResRowSet.CurrentRow.GetParam(IRobotResultParamType.I_RPT_PANEL);
                ///if already got in error list
                if (ErrorList.Any(g => g.Contains($"number {p} isn't")))
                {
                    goto ExitPlate;
                }

                var nodeId = (int)RobResRowSet.CurrentRow.GetParam(IRobotResultParamType.I_RPT_NODE);
                //var eeId = (int)RobResRowSet.CurrentRow.GetParam(IRobotResultParamType.I_RPT_ELEMENT);
                for (int x = 0; x < Panel.Count; x++)
                {
                    for (int y = 0; y < Panel[x].nodes.Count; y++)
                    {
                        if (Panel[x].nodes[y].NodeId == nodeId)
                        {
                            ///check if there is result for slab
                            if (!RobResRowSet.CurrentRow.IsAvailable(RobResRowSet.ResultIds.Get(3)))
                            {
                                ErrorList.Add($"Slabs with number {p} isn't calculated for reinforcement");
                                goto ExitPlate;
                            }

                            Panel[x].nodes[y].AX_BOTTOM = Math.Round((double)RobResRowSet.CurrentRow.GetValue(RobResRowSet.ResultIds.Get(3)) * 10000, 3);
                            Panel[x].nodes[y].AY_BOTTOM = Math.Round((double)RobResRowSet.CurrentRow.GetValue(RobResRowSet.ResultIds.Get(4)) * 10000, 3);
                            Panel[x].nodes[y].AX_TOP    = Math.Round((double)RobResRowSet.CurrentRow.GetValue(RobResRowSet.ResultIds.Get(1)) * 10000, 3);
                            Panel[x].nodes[y].AY_TOP    = Math.Round((double)RobResRowSet.CurrentRow.GetValue(RobResRowSet.ResultIds.Get(2)) * 10000, 3);
                            Panel[x].nodes[y].X         = (double)RobResRowSet.CurrentRow.GetValue(RobResRowSet.ResultIds.Get(5));
                            Panel[x].nodes[y].Y         = (double)RobResRowSet.CurrentRow.GetValue(RobResRowSet.ResultIds.Get(6));
                            Panel[x].nodes[y].Z         = (double)RobResRowSet.CurrentRow.GetValue(RobResRowSet.ResultIds.Get(7));
                        }
                    }
                }
ExitPlate:
                i++;
                ok = RobResRowSet.MoveNext();
            }

            if (ErrorList.Count == ObjNumbers.Length)
            {
                throw new SlabNotCalculatedForReinfException
                          ("None of selected slabs are calculated for reinforcement");
            }

            progress.Report(new ProgressModelObject <double>
            {
                ProgressToString = "Done collectiong done!", Progress = 10 * 10
            });
            IsDataCollected = true;
        }
示例#2
0
        /// <summary>
        /// Gets the FE meshes from a Robot model using the fast query method
        /// </summary>
        /// <param name="panel_ids"></param>
        /// <param name="coords"></param>
        /// <param name="vertex_indices"></param>
        /// <param name="str_nodes"></param>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public static bool GetFEMeshQuery(out int[] panel_ids, out double[][] coords, out Dictionary <int, int[]> vertex_indices, string filePath = "LiveLink")
        {
            RobotApplication robot = null;

            if (filePath == "LiveLink")
            {
                robot = new RobotApplication();
            }

            //First call getnodesquery to get node points
            double[][] nodeCoords = null;

            //Dictionary<int, BHoM.Structural.Node> _str_nodes = new Dictionary<int, BHoM.Structural.Node>();
            //RobotToolkit.Node.GetNodesQuery(project, filePath);
            //Dictionary<int, int> _nodeIds = new Dictionary<int, int>();
            //for (int i = 0; i < _str_nodes.Count; i++)
            //{
            //    _nodeIds.Add(_str_nodes.ElementAt(i).Value.Number, i);
            //}

            RobotResultQueryParams      result_params = (RobotResultQueryParams)robot.Kernel.CmpntFactory.Create(IRobotComponentType.I_CT_RESULT_QUERY_PARAMS);
            RobotStructure              rstructure    = robot.Project.Structure;
            RobotSelection              FE_sel        = rstructure.Selections.CreateFull(IRobotObjectType.I_OT_FINITE_ELEMENT);
            IRobotResultQueryReturnType query_return  = IRobotResultQueryReturnType.I_RQRT_MORE_AVAILABLE;
            RobotSelection              cas_sel       = rstructure.Selections.Create(IRobotObjectType.I_OT_CASE);

            try { cas_sel.FromText(robot.Project.Structure.Cases.Get(1).Number.ToString()); } catch { }

            if (cas_sel.Count > 0)
            {
                result_params.Selection.Set(IRobotObjectType.I_OT_CASE, cas_sel);
            }

            //result_params.Selection.Set(IRobotObjectType.I_OT_NODE, FE_sel);

            result_params.SetParam(IRobotResultParamType.I_RPT_MULTI_THREADS, true);
            result_params.SetParam(IRobotResultParamType.I_RPT_THREAD_COUNT, 4);
            result_params.SetParam(IRobotResultParamType.I_RPT_SMOOTHING, IRobotFeResultSmoothing.I_FRS_NO_SMOOTHING);
            result_params.SetParam(IRobotResultParamType.I_RPT_DIR_X_DEFTYPE, IRobotObjLocalXDirDefinitionType.I_OLXDDT_CARTESIAN);
            result_params.SetParam(IRobotResultParamType.I_RPT_DIR_X, new double[] { 1, 0, 0 });

            result_params.SetParam(IRobotResultParamType.I_RPT_NODE, 1);
            result_params.SetParam(IRobotResultParamType.I_RPT_PANEL, 1);
            result_params.SetParam(IRobotResultParamType.I_RPT_ELEMENT, 1);
            result_params.SetParam(IRobotResultParamType.I_RPT_RESULT_POINT_COORDINATES, 1);

            result_params.ResultIds.SetSize(2);
            result_params.ResultIds.Set(1, (int)IRobotFeResultType.I_FRT_DETAILED_MXX);
            result_params.ResultIds.Set(2, (int)IRobotFeResultType.I_FRT_DETAILED_MYY);

            RobotResultRowSet row_set = new RobotResultRowSet();
            bool           ok         = false;
            RobotResultRow result_row = default(RobotResultRow);

            List <int> _panel_ids = new List <int>();
            Dictionary <int, int[]> _vertex_indices = new Dictionary <int, int[]>();
            int kounta = 0;

            while (!(query_return == IRobotResultQueryReturnType.I_RQRT_DONE))
            {
                query_return = rstructure.Results.Query(result_params, row_set);
                ok           = row_set.MoveFirst();
                while (ok)
                {
                    //int panel_num = (int)row_set.CurrentRow.GetValue(1252);
                    //_panel_ids.Add(panel_num);

                    int nodeId = (int)row_set.CurrentRow.GetParam(IRobotResultParamType.I_RPT_NODE);
                    //int panelId = (int)row_set.CurrentRow.GetParam(IRobotResultParamType.I_RPT_PANEL);
                    int elementId = (int)row_set.CurrentRow.GetParam(IRobotResultParamType.I_RPT_ELEMENT);

                    //int number_of_indices = (row_set.CurrentRow.IsAvailable(567)) ? 4 : 3;
                    //int[] temp_indices = new int[number_of_indices];
                    //for (int i = 0; i < number_of_indices; i++)
                    //{
                    //    temp_indices[i] = (int)row_set.CurrentRow.GetValue(564 + i);
                    //}

                    var resultIds = row_set.ResultIds;

                    var xxxx = row_set.CurrentRow.GetParam(IRobotResultParamType.I_RPT_RESULT_POINT_COORDINATES);



                    //_vertex_indices.Add(kounta, temp_indices);
                    //kounta++;
                    ok = row_set.MoveNext();
                }
                row_set.Clear();
            }
            result_params.Reset();

            panel_ids      = _panel_ids.ToArray();
            vertex_indices = _vertex_indices;
            coords         = nodeCoords;
            //str_nodes = _str_nodes;
            return(true);
        }