(API) Speed up API (Extract results)

alfredmx
Advocate
Advocate

(API) Speed up API (Extract results)

alfredmx
Advocate
Advocate

Hello,

 

I need to extract panel node results from multiple model files.

I'm using the following code to extract results:

 

'-----------------------------------------

 

Dim robotapp As IRobotApplication

robotapp = New RobotApplication

 

For i = 1 To grid1.Rows.Count - 2

 

robotapp.Project.Open(vecrutafile(i - 1))

robotapp.Project.Preferences.Units.Refresh()

 

Dim filename As String

filename = "\" & grid1(i, 1) & "_" & txtfile2pan.Text & ".csv"

Dim objWriter As New IO.StreamWriter(savepath & filename)

 

Dim RSelection As RobotSelection

RSelection = robotapp.Project.Structure.Selections.Create(IRobotObjectType.I_OT_PANEL)

RSelection.FromText(elem)

Dim panelcoll As RobotObjObjectCollection

panelcoll = robotapp.Project.Structure.Objects.GetMany(RSelection)

 

Dim FileLines As String

FileLines = ""

FileLines = "Panel,Node,Case,UXX (cm),UYY (cm),WNorm. (cm),RXX (Deg),RYY (Deg)" & vbCrLf

 

For j = 1 To panelcoll.Count

 

Dim obj As IRobotObjObject

obj = panelcoll.Get(j)

Dim panelnum As Long

panelnum = obj.Number

Dim nodes As String

Dim nodesel As RobotSelection

Dim nodecoll As RobotNodeCollection

nodes = obj.Nodes

nodesel = robotapp.Project.Structure.Selections.Create(IRobotObjectType.I_OT_NODE)

nodesel.FromText(nodes)

nodecoll = robotapp.Project.Structure.Nodes.GetMany(nodesel)

Dim FEparams As New RobotFeResultParams

 

If combolayer.SelectedIndex = 0 Then

FEparams.Layer = IRobotFeLayerType.I_FLT_UPPER

ElseIf combolayer.SelectedIndex = 1 Then

FEparams.Layer = IRobotFeLayerType.I_FLT_MIDDLE

ElseIf combolayer.SelectedIndex = 2 Then

FEparams.Layer = IRobotFeLayerType.I_FLT_LOWER

Else

End If

 

FEparams.SetDirX(IRobotObjLocalXDirDefinitionType.I_OLXDDT_UNDEFINED, 0, 0, 0)

 

For k = 1 To nodecoll.Count

 

Dim node As IRobotNode

node = nodecoll.Get(k)

Dim nodenum As Long

nodenum = node.Number

FEparams.Node = node.Number

FEparams.Case = caso

Dim FEresults As RobotFeResultDetailed

FEresults = robotapp.Project.Structure.Results.FiniteElems.Detailed(FEparams)

 

FileLines = FileLines & " " & panelnum & ", " & nodenum & ", " & caso & ","

FileLines = FileLines & Format(FEresults.UXX * 100, "0.000") & ","

FileLines = FileLines & Format(FEresults.UYY * 100, "0.000") & ","

FileLines = FileLines & Format(FEresults.WNorm * 100, "0.000") & ","

FileLines = FileLines & Format(FEresults.RXX * (180 / Math.PI), "0.000") & ","

FileLines = FileLines & Format(FEresults.RYY * (180 / Math.PI), "0.000") & vbCrLf

 

Next

 

Next

 

objWriter.Write(FileLines)

objWriter.Close()

 

robotapp.Project.Close()

 

 Next

 

robotapp.Quit(IRobotQuitOption.I_QO_DISCARD_CHANGES)

 

'-----------------------------------------

 

The problem is that extracting results for each model is taking up to 8min (larger models with aprox 300 panels and 80 nodes per panel), and total number of models is around 80.

 

Is there any way to speed up the process?

 

Regards,

 

0 Likes
Reply
Accepted solutions (2)
3,296 Views
21 Replies
Replies (21)

Rafal.Gaweda
Autodesk Support
Autodesk Support
0 Likes

alfredmx
Advocate
Advocate

Hello Rafal,

 

Thanks a lot for your help. I will give it a try. Is it possible to have example code in VB?, I'm not very familiar with C++ syntax.

 

Regards,

 

0 Likes

Rafal.Gaweda
Autodesk Support
Autodesk Support
Accepted solution
Private Sub CommandButton2_Click()


Dim RobApp As New RobotOM.RobotApplication

Dim Res As IRobotResultQueryReturnType
Dim RobResQueryParams As RobotResultQueryParams
Dim RobResRowSet As New RobotResultRowSet

Dim SelPanel As RobotSelection
Dim SelCas As RobotSelection

Set SelPanel = RobApp.Project.Structure.Selections.Create(I_OT_PANEL)
Set SelCas = RobApp.Project.Structure.Selections.Create(I_OT_CASE)
SelPanel.FromText ("all")
SelCas.FromText ("all")

Set RobResQueryParams = RobApp.CmpntFactory.Create(I_CT_RESULT_QUERY_PARAMS)
RobResQueryParams.ResultIds.SetSize (1)
RobResQueryParams.Selection.Set I_OT_PANEL, SelPanel
RobResQueryParams.Selection.Set I_OT_CASE, SelCas
RobResQueryParams.SetParam I_RPT_MAX_BUFFER_SIZE, 2000000
RobResQueryParams.SetParam I_RPT_SMOOTHING, I_FRS_SMOOTHING_WITHIN_A_PANEL
RobResQueryParams.SetParam I_RPT_LAYER, I_FLT_ABSOLUTE_MAXIMUM
RobResQueryParams.SetParam I_RPT_DIR_X_DEFTYPE, I_OLXDDT_CARTESIAN
RobResQueryParams.SetParam I_RPT_DIR_X, 1, 0, 0

RobResQueryParams.ResultIds.Set 1, I_FRT_DETAILED_TXX


'Set Res = RobApp.Project.Structure.Results.Query(RobResQueryParams, RobResRowSet)

'Dim q As New Object
Dim v As Double

Dim max As Double
Dim min As Double
max = 0
min = 0

Do
 Res = RobApp.Project.Structure.Results.Query(RobResQueryParams, RobResRowSet)
Dim ok As Boolean
ok = RobResRowSet.MoveFirst()
While ok
v = RobResRowSet.CurrentRow.GetValue(RobResRowSet.ResultIds.Get(1))
If (min > v) Then min = v
If (max < v) Then max = v
ok = RobResRowSet.MoveNext()
Wend
Loop While Res = I_RQRT_MORE_AVAILABLE

MsgBox ("min = " & min & " max = " & max)
End Sub

 



Rafal Gaweda
0 Likes

alfredmx
Advocate
Advocate

Hello Rafal,

 

I'm using the following code:

 

'_____________

 

Dim Res As IRobotResultQueryReturnType

Dim RobResQueryParams As RobotResultQueryParams

Dim RobResRowSet As New RobotResultRowSet

 

Dim RSelection As RobotSelection

RSelection = robotapp.Project.Structure.Selections.Create(IRobotObjectType.I_OT_PANEL)

RSelection.FromText(elem)

Dim RSelectioncase As RobotSelection

RSelectioncase = robotapp.Project.Structure.Selections.Create(IRobotObjectType.I_OT_CASE)

RSelectioncase.FromText(Convert.ToString(caso))

 

Dim FileLines As String

FileLines = ""

FileLines = "Panel,Node,Case,UXX (cm),UYY (cm),WNorm. (cm),RXX (Deg),RYY (Deg)" & vbCrLf

 

RobResQueryParams = robotapp.CmpntFactory.Create(IRobotComponentType.I_CT_RESULT_QUERY_PARAMS)

RobResQueryParams.ResultIds.SetSize(5)

RobResQueryParams.Selection.Set(IRobotObjectType.I_OT_PANEL, RSelection)

RobResQueryParams.Selection.Set(IRobotObjectType.I_OT_CASE, RSelectioncase)

RobResQueryParams.SetParam(IRobotResultParamType.I_RPT_MAX_BUFFER_SIZE, 2000000)

RobResQueryParams.SetParam(IRobotResultParamType.I_RPT_SMOOTHING, IRobotFeResultSmoothing.I_FRS_GLOBAL_SMOOTHING)

 

If combolayer.SelectedIndex = 0 Then

RobResQueryParams.SetParam(IRobotResultParamType.I_RPT_LAYER, IRobotFeLayerType.I_FLT_UPPER)

ElseIf combolayer.SelectedIndex = 1 Then

RobResQueryParams.SetParam(IRobotResultParamType.I_RPT_LAYER, IRobotFeLayerType.I_FLT_MIDDLE)

ElseIf combolayer.SelectedIndex = 2 Then

RobResQueryParams.SetParam(IRobotResultParamType.I_RPT_LAYER, IRobotFeLayerType.I_FLT_LOWER)

Else

End If

 

RobResQueryParams.SetParam(IRobotResultParamType.I_RPT_DIR_X_DEFTYPE, IRobotObjLocalXDirDefinitionType.I_OLXDDT_UNDEFINED)

'RobResQueryParams.SetParam(I_RPT_DIR_X, 1, 0, 0)

RobResQueryParams.ResultIds.Set(1, IRobotFeResultType.I_FRT_DETAILED_UXX)

RobResQueryParams.ResultIds.Set(2, IRobotFeResultType.I_FRT_DETAILED_UYY)

RobResQueryParams.ResultIds.Set(3, IRobotFeResultType.I_FRT_DETAILED_WNORM)

RobResQueryParams.ResultIds.Set(4, IRobotFeResultType.I_FRT_DETAILED_RXX)

RobResQueryParams.ResultIds.Set(5, IRobotFeResultType.I_FRT_DETAILED_RYY)

 

Res = robotapp.Project.Structure.Results.Query(RobResQueryParams, RobResRowSet)

 

Do While Res = IRobotResultQueryReturnType.I_RQRT_MORE_AVAILABLE

 

Dim ok As Boolean

ok = RobResRowSet.MoveFirst()

 

While ok

FileLines = FileLines & Format(RobResRowSet.CurrentRow.GetValue(RobResRowSet.ResultIds.Get(1)) * 100, "0.000") & ","

FileLines = FileLines & Format(RobResRowSet.CurrentRow.GetValue(RobResRowSet.ResultIds.Get(2)) * 100, "0.000") & ","

FileLines = FileLines & Format(RobResRowSet.CurrentRow.GetValue(RobResRowSet.ResultIds.Get(3)) * 100, "0.000") & ","

FileLines = FileLines & Format(RobResRowSet.CurrentRow.GetValue(RobResRowSet.ResultIds.Get(4)) * (180 / Math.PI), "0.000") & ","

FileLines = FileLines & Format(RobResRowSet.CurrentRow.GetValue(RobResRowSet.ResultIds.Get(5)) * (180 / Math.PI), "0.000") & vbCrLf

ok = RobResRowSet.MoveNext()

End While

 

Res = robotapp.Project.Structure.Results.Query(RobResQueryParams, RobResRowSet)

Loop

 

'_____________

 

It seems to be working fine, because "FileLines" captures some results, but at some point within "While ok" loop a COM exception crashes the procees with HRESULT E_FAIL error. Any ideas?

 

Regards,

 

 

 

 

 

 

0 Likes

Rafal.Gaweda
Autodesk Support
Autodesk Support
It works fine.
Try to register Robot as admin.
If it does not help - send us Robot file to check it with this code.


Rafal Gaweda
0 Likes

alfredmx
Advocate
Advocate

Hello Rafal,

 

By register Robot as admin you mean post 8 in this topic, or just "Run as admin"?

 

http://forums.autodesk.com/t5/robot-structural-analysis/vba-excel-macro-for-any-object-geometry-modi...

 

Regards,

0 Likes

Rafal.Gaweda
Autodesk Support
Autodesk Support

post 8



Rafal Gaweda
0 Likes

alfredmx
Advocate
Advocate

Hello Rafal,

 

Sorry for the delay. I've been busy with an upcoming structural drawings delivery. In the meantime, I've been using current (slow) code to extract results from all model files. I will try suggested solution as soon as I have some free time. Thanks a lot for your help.

 

Regards,

 

 

0 Likes

Anonymous
Not applicable
Hello, I'm currently trying to get the maximum principal stress inside FE panels and I bumped into the query solution (getting the results with the extreme result server gives inacurate results). I work with VBA from Excel and when I try to create the RobotResultRowSet object I get an error 429. I tried both with early and late binding : - Dim rowset as New RobotResultRowSet - Dim rowset as Object; Set rowset = CreateObject("Robot.ResultRowSet") but they both give the same error on the object's creation. I tried unregistering and registering robot.exe (with /unregserver) as admin, as suggested in other posts but that did nothing I also tried running Robot and/or excel as admin but it dosen't work neither. I even checked the class in the register and "Robot.ResultRowSet" exists in HKEY_CLASSES_ROOT with a supplied class id. Do you have a solution ? Thanks, Regards. PS : To the admin team : Since a few weeks, I can't seem to display the topic list in the forum board, or even create a new post in this board. I tried with both firefox and IE and the result is exactly the same. Is there a workaround ?
0 Likes

Anonymous
Not applicable
Sorry, retrying to post with the right formatrting : Hello, I'm currently trying to get the maximum principal stress inside FE panels and I bumped into the query solution (getting the results with the extreme result server gives inacurate results). I work with VBA from Excel and when I try to create the RobotResultRowSet object I get an error 429. I tried both with early and late binding : - Dim rowset as New RobotResultRowSet - Dim rowset as Object; Set rowset = CreateObject("Robot.ResultRowSet") but they both give the same error on the object's creation. I tried unregistering and registering robot.exe (with /unregserver) as admin, as suggested in other posts but that did nothing I also tried running Robot and/or excel as admin but it dosen't work neither. I even checked the class in the register and "Robot.ResultRowSet" exists in HKEY_CLASSES_ROOT with a supplied class id. Do you have a solution ? Thanks, Regards. PS : To the admin team : Since a few weeks, I can't seem to display the topic list in the forum board, or even create a new post in this board. I tried with both firefox and IE and the result is exactly the same. Is there a workaround ?
0 Likes

Rafal.Gaweda
Autodesk Support
Autodesk Support
0 Likes

thomas.channell
Contributor
Contributor

Could anyone point me in the direction of being able to achieve the above but for results for bars? I.E. forces and moments in a bar? I have had a look at changing the "IRobotFeResultType" but can't find an alternative.

0 Likes

Rafal.Gaweda
Autodesk Support
Autodesk Support
Accepted solution

Hi @thomas.channell

 

Here is example for bars

 

Private Sub CommandButton2_Click()

Dim RobApp As New RobotOM.RobotApplication

Dim Res As IRobotResultQueryReturnType
Dim RobResQueryParams As RobotResultQueryParams
Dim RobResRowSet As New RobotResultRowSet

Dim SelBar As RobotSelection
Dim SelCas As RobotSelection

Set SelBar = RobApp.Project.Structure.Selections.Create(I_OT_BAR)
Set SelCas = RobApp.Project.Structure.Selections.Create(I_OT_CASE)
SelBar.AddText ("1")
SelCas.AddText ("1")

Set RobResQueryParams = RobApp.CmpntFactory.Create(I_CT_RESULT_QUERY_PARAMS)
RobResQueryParams.Selection.Set I_OT_BAR, SelBar
RobResQueryParams.Selection.Set I_OT_CASE, SelCas
RobResQueryParams.SetParam I_RPT_BAR_ELEMENT_DIV_COUNT, 11

RobResQueryParams.ResultIds.SetSize (6)

RobResQueryParams.ResultIds.Set 1, I_EVT_FORCE_BAR_FX
RobResQueryParams.ResultIds.Set 2, I_EVT_FORCE_BAR_FY
RobResQueryParams.ResultIds.Set 3, I_EVT_FORCE_BAR_FZ
RobResQueryParams.ResultIds.Set 4, I_EVT_FORCE_BAR_MX
RobResQueryParams.ResultIds.Set 5, I_EVT_FORCE_BAR_MY
RobResQueryParams.ResultIds.Set 6, I_EVT_FORCE_BAR_MZ

'Set Res = RobApp.Project.Structure.Results.Query(RobResQueryParams, RobResRowSet)

'Dim q As New Object
Dim v As Double

Dim max As Double
Dim min As Double
max = 0
min = 0

Do
 Res = RobApp.Project.Structure.Results.Query(RobResQueryParams, RobResRowSet)
Dim ok As Boolean
ok = RobResRowSet.MoveFirst()
While ok
v = RobResRowSet.CurrentRow.GetValue(RobResRowSet.ResultIds.Get(5))
If (min > v) Then min = v
If (max < v) Then max = v
ok = RobResRowSet.MoveNext()
Wend
Loop While Res = I_RQRT_MORE_AVAILABLE

MsgBox ("min = " & min & " max = " & max)
End Sub


Rafal Gaweda

thomas.channell
Contributor
Contributor

I am working in C# and am trying to instantiate the class below like:

 

RobotResultRowSet RobResRowSet = new RobotResultRowSet();

 

... but I then get the following error?

 

System.Runtime.InteropServices.COMException: 'Retrieving the COM class factory for component with CLSID {F335E413-5241-418C-9421-A4D1B545F923} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).'

 

Any ideas?

0 Likes

Rafal.Gaweda
Autodesk Support
Autodesk Support

Hi @thomas.channell

 

 

It must be 64 bit application \ exe as a result

Queryparams is only 64 bit.



Rafal Gaweda
0 Likes

thomas.channell
Contributor
Contributor

Thanks for this :).

 

If we are running a 32 bit application/.exe, how much depreciation in speed would we expect.

 

Currently performing any interaction seems to lag a bit, hence the question.

0 Likes

thomas.channell
Contributor
Contributor

Also, further to this, if there are any other methods of getting the results data out of Robot other than this method above and the method below?

 

RobotBarForceData forceData = robApp.Project.Structure.Results.Bars.Forces.Value(Convert.ToInt16(member.id), caseNumber, Point);

 

0 Likes

Rafal.Gaweda
Autodesk Support
Autodesk Support

Hi @thomas.channell

 

how much depreciation in speed would we expect.

 

 

It depends on model size and amount of results. I can say,  in general, "significant" difference.



Rafal Gaweda
0 Likes

Rafal.Gaweda
Autodesk Support
Autodesk Support

 

Hi @thomas.channell

 

Also, further to this, if there are any other methods of getting the results data out of Robot other than this method above and the method below?

 

RobotBarForceData forceData = robApp.Project.Structure.Results.Bars.Forces.Value(Convert.ToInt16(member.id), caseNumber, Point);

 

 

The above line in faster way, especially if you will use BarForceServer.Value(...)   in the loop:

 

 

Dim BarForceServer As RobotBarForceServer
Set BarForceServer = RobApp.Project.Structure.Results.Bars.Forces
Dim BFD As RobotBarForceData

For i = 1 To BarCol.Count Set BFD = BarForceServer.Value(....)
.....
Next i

 

 

You will find other servers in Robot API

 

 

Methods depend on your choice. You can use also:

 

RobApp.Project.Structure.Results.Extremes....

 

 

 



Rafal Gaweda
0 Likes