Hi All,
I am trying to improve the speed of extracting Robot results using the RobotResultQueryParams approach. I have read through all the posts but cant understand why RobotResultQueryParams always returns "I_RQRT_DONE". Here is my code:
//Set the selection for all finite elements RobotSelection FESelection = robApp.Project.Structure.Selections.Create(IRobotObjectType.I_OT_FINITE_ELEMENT); FESelection.FromText("All"); //Set the selection for all load cases RobotSelection CasSelection = robApp.Project.Structure.Selections.Create(IRobotObjectType.I_OT_CASE); CasSelection.FromText("All"); //set the selection for all panels RobotSelection PanSelection = robApp.Project.Structure.Selections.Create(IRobotObjectType.I_OT_PANEL); PanSelection.FromText("All"); //set the selection for all nodes RobotSelection NodSelection = robApp.Project.Structure.Selections.Create(IRobotObjectType.I_OT_NODE); NodSelection.FromText("All"); //Fast Method IRobotResultQueryReturnType Res; RobotResultQueryParams RobResQueryParams; RobotResultRowSet RobResRowSet = new RobotResultRowSet(); RobResQueryParams = robApp.CmpntFactory.Create(IRobotComponentType.I_CT_RESULT_QUERY_PARAMS); RobResQueryParams.SetParam(IRobotResultParamType.I_RPT_MULTI_THREADS, true); RobResQueryParams.SetParam(IRobotResultParamType.I_RPT_THREAD_COUNT, 4); RobResQueryParams.SetParam(IRobotResultParamType.I_RPT_SMOOTHING, IRobotFeResultSmoothing.I_FRS_SMOOTHING_WITHIN_A_PANEL); RobResQueryParams.SetParam(IRobotResultParamType.I_RPT_LAYER, IRobotFeLayerType.I_FLT_MIDDLE); //RobResQueryParams.Selection.Set(IRobotObjectType.I_OT_FINITE_ELEMENT, FESelection); //RobResQueryParams.Selection.Set(IRobotObjectType.I_OT_PANEL, PanSelection); RobResQueryParams.Selection.Set(IRobotObjectType.I_OT_FINITE_ELEMENT, NodSelection); RobResQueryParams.Selection.Set(IRobotObjectType.I_OT_CASE, CasSelection); RobResQueryParams.ResultIds.SetSize(8); RobResQueryParams.ResultIds.Set(1, 501); //IRobotFeResultType.I_FRT_DETAILED_MXX RobResQueryParams.ResultIds.Set(2, 502); //IRobotFeResultType.I_FRT_DETAILED_MYY RobResQueryParams.ResultIds.Set(3, 503); //IRobotFeResultType.I_FRT_DETAILED_MXY RobResQueryParams.ResultIds.Set(4, 492); //IRobotFeResultType.I_FRT_DETAILED_NXX RobResQueryParams.ResultIds.Set(5, 493); //IRobotFeResultType.I_FRT_DETAILED_NYY RobResQueryParams.ResultIds.Set(6, 494); //IRobotFeResultType.I_FRT_DETAILED_NXY RobResQueryParams.ResultIds.Set(7, 519); //IRobotFeResultType.I_FRT_DETAILED_QXX RobResQueryParams.ResultIds.Set(8, 520); //IRobotFeResultType.I_FRT_DETAILED_QYY Res = robApp.Project.Structure.Results.Query(RobResQueryParams, RobResRowSet);
Problem is with the last line "Res =...."
Has anyone got any idea why this is as I have tried multiple combinations of selecting cases with elements, nodes and finite elements.
Thank you!
That's a good sign. 😀
Now, you have all the results and you need to go thru then like this:
Dim ok As Boolean
ok = RobResRowSet.MoveFirst()
If ok = False Then Exit Do
While ok
' do something with values and parameters
'RobResRowSet.CurrentRow.GetParam(I_RPT_PANEL)
'RobResRowSet.CurrentRow.GetParam(I_RPT_NODE))
'RobResRowSet.CurrentRow.GetParam(I_RPT_LOAD_CASE))
'RobResRowSet.CurrentRow.GetValue(RobResRowSet.ResultIds.Get(1)) * 0.001
'...
ok = RobResRowSet.MoveNext()
Wend
regards
I was expecting that it should return "I_RQRT_MORE_AVAILABLE"?
This is because the rest of my code is like this:
while (Res == IRobotResultQueryReturnType.I_RQRT_MORE_AVAILABLE) { bool ok = RobResRowSet.MoveFirst(); while (ok) { numCas = RobResRowSet.CurrentRow.GetParam(IRobotResultParamType.I_RPT_LOAD_CASE); numFe = RobResRowSet.CurrentRow.GetParam(IRobotResultParamType.I_RPT_ELEMENT); res_nxx = RobResRowSet.CurrentRow.GetValue(RobResRowSet.ResultIds.Get(1)); res_nyy = RobResRowSet.CurrentRow.GetValue(RobResRowSet.ResultIds.Get(2)); res_nxy = RobResRowSet.CurrentRow.GetValue(RobResRowSet.ResultIds.Get(3)); res_mxx = RobResRowSet.CurrentRow.GetValue(RobResRowSet.ResultIds.Get(4)); res_myy = RobResRowSet.CurrentRow.GetValue(RobResRowSet.ResultIds.Get(5)); res_mxy = RobResRowSet.CurrentRow.GetValue(RobResRowSet.ResultIds.Get(6)); res_qxx = RobResRowSet.CurrentRow.GetValue(RobResRowSet.ResultIds.Get(7)); res_qyy = RobResRowSet.CurrentRow.GetValue(RobResRowSet.ResultIds.Get(8)); //write to file here
ok = RobResRowSet.MoveNext(); } Res = robApp.Project.Structure.Results.Query(RobResQueryParams, RobResRowSet); }
I have forced the code to jump into the while (ok) loop by manually overriding Res to equal "I_RQRT_MORE_AVAILABLE". But when I do this, the code breaks down on this line:
numFe = RobResRowSet.CurrentRow.GetParam(IRobotResultParamType.I_RPT_ELEMENT);
I get this error: "System.Runtime.InteropServices.COMException: 'Error HRESULT E_FAIL has been returned from a call to a COM component.'"
When I remove this line, the code executes perfectly! I want the line above to give me the finite element number.
On another note, the results come out in the following order: 1. load case 2. element. e.g.
Load Element Results...... 1 1 results here...
2 1 results here...
3 1 results here...
1 2 results here...
2 2 results here...
3 2 results here...
etc...
I want the results to be produced like this:
Load Element Results...... 1 1 results here... 1 2 results here... 2 1 results here... 2 2 results here... 3 1 results here... 3 2 results here... etc...
Thanks a lot!!!
In your first post if you get, if you get I_RQRT_DONE, then you already have all results. If you get I_RQRT_MORE_AVAILABLE then you get only a part of your results and you should call your function again to get the other part, and so on... see API manual that gives you this info...
RobResRowSet.CurrentRow.GetParam(IRobotResultParamType.I_RPT_ELEMENT)
I think it is not implemeted in API please see
Regarding order, I don't know how to control that (nor if there is a way). So after I get all the results (in a transient matrix for ex...) then I reorder as I want and finally put the results in the final place...
Sorry for not helping you more... regards
Thanks for the reply.
Surely there must be a way to get the finite element number for each of the results! Otherwise how do I know which finite element the results are for?
I’ll have to manipulate the results to get them into the right format then, which isn’t a problem.
"Surely there must be a way to get the finite element number for each of the results! Otherwise how do I know which finite element the results are for?" That's a good question for developers 😁. Maybe @Rafal.Gaweda can help you with this!
In this example, it is not a problem because you are asking results smoothed within panel, so you only need to know the node and the panel.
Regards
Can't find what you're looking for? Ask the community or share your knowledge.