(API) Speed up API (Extract results)

(API) Speed up API (Extract results)

alfredmx
Advocate Advocate
4,048 Views
21 Replies
Message 1 of 22

(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
Accepted solutions (2)
4,049 Views
21 Replies
Replies (21)
Message 21 of 22

Anonymous
Not applicable

Hello Rafal,

 

I've tried to run the code you posted but I have some problems with it.

it seems there is some problem with RobResRowSet because excels returns me the next error

 

Object variable not settled down

 

Any Idea??

 

Thanks!

0 Likes
Message 22 of 22

marcinrakus
Autodesk
Autodesk

Hi,

 

Make sure, You fulfilled all requirements that were listed in previous posts (registration, 64 bits (Excel has to be 64 bits as well), administrator rights, and so on).

Sometimes there has to be a 'Set' command added on excel, or some other syntax error (like brackets or something), but I this this is not a case.

You may also check different selection, different parameters of result query.

 

If that fails attach excel file and rtd example.

 

Regards,

Marcin