ROBOT - API - VB.NET - Performance

ROBOT - API - VB.NET - Performance

Temo_Escudero
Participant Participant
2,152 Views
8 Replies
Message 1 of 9

ROBOT - API - VB.NET - Performance

Temo_Escudero
Participant
Participant

Hi there!

I have a question regarding the performance of extracting information from ROBOT. Maybe the poor performance I am getting is because I am doing something terribly wrong.

What I am trying to do is to extract the finite element information, such as conectivities, labels, and also the nodal information only of the subset of selected FEs.

 

This is an example of a loop over finite elements:

        Dim rbtSel_FEs = Me._robApp.Project.Structure.Selections.Get(IRobotObjectType.I_OT_FINITE_ELEMENT)
        rbtSel_FEs.FromText(listFEs)
        Dim FEsCollection As IRobotCollection = Me._robApp.Project.Structure.FiniteElems.GetMany(rbtSel_FEs)
        Dim iKont As Integer = 0

        For II = 1 To FEsCollection.Count
            iKont += 1
            Dim kFE As IRobotFiniteElement
            kFE = FEsCollection.Get(iKont)
            Dim iFE As ItemFE = New ItemFE
            iFE.ID = kFE.Number
            iFE.N1 = kFE.Nodes.Get(1)
            iFE.N2 = kFE.Nodes.Get(2)
            iFE.N3 = kFE.Nodes.Get(3)

            If (kFE.FeType = IRobotFiniteElementType.I_FET_T3) Then
                iFE.FE_Type = "I_FET_T3"
                iFE.N4 = -1
            ElseIf (kFE.FeType = IRobotFiniteElementType.I_FET_Q4) Then
                iFE.FE_Type = "I_FET_Q4"
                iFE.N4 = kFE.Nodes.Get(4)
            End If

            Me.theFEs.Add(iFE)
        Next

This is the other loop that take ages, 

        For Each iFE As ItemFE In Me.theFEs
            'Nodo 1...
            If (Me.theNodes.posVec(iFE.N1 - 1) = -1) Then
                kPos += 1
                Me.theNodes.posVec(iFE.N1 - 1) = kPos
                iNode = getNodalInfo(iFE.N1)
                Me.theNodes.Items.Add(iNode)
            End If

            'Nodo 2...
            If (Me.theNodes.posVec(iFE.N2 - 1) = -1) Then
                kPos += 1
                Me.theNodes.posVec(iFE.N2 - 1) = kPos
                iNode = getNodalInfo(iFE.N2)
                Me.theNodes.Items.Add(iNode)
            End If

            'Nodo 3...
            If (Me.theNodes.posVec(iFE.N3 - 1) = -1) Then
                kPos += 1
                Me.theNodes.posVec(iFE.N3 - 1) = kPos
                iNode = getNodalInfo(iFE.N3)
                Me.theNodes.Items.Add(iNode)
            End If

        Next

    Private Function getNodalInfo(ByVal iNode As Integer) As ItemNode
        Dim nodeToReturn As ItemNode = New ItemNode

        Dim rbtSel_Node = Me._robApp.Project.Structure.Selections.Get(IRobotObjectType.I_OT_NODE)
        rbtSel_Node.FromText(iNode.ToString)
        Dim pointCollection As IRobotCollection = Me._robApp.Project.Structure.Nodes.GetMany(rbtSel_Node)
        Dim iPoint As IRobotNode
        iPoint = pointCollection.Get(1)
        nodeToReturn.ID = iNode
        nodeToReturn.X = iPoint.X
        nodeToReturn.Y = iPoint.Y
        nodeToReturn.Z = iPoint.Z

        Return nodeToReturn
    End Function

 

Also at the begining of the process I am doing this: robApp.Interactive = 0. In such a way I expect the process to finish in like 6 hours to get the info of 69000 FEs and 45000 nodes. The specs of the PC are: 64Gb of RAM and AMD Ryzen 7 2700 Eight-Core.

 

I would kindly appreciate if someone can tell me if in someone's experience this performance I am getting is ridiculously poor. In my experience they are, compared with other pre-processors.

Greetings!

0 Likes
2,153 Views
8 Replies
Replies (8)
Message 2 of 9

rsousa_
Advocate
Advocate

I'm no expert, but I can give you my personal experience.

 

"COM" connections have, in general, very poor perfomance. This is valid for ROBOT, EXCEL and so on... And if if you don't do "special" programming, you don't take advantage of you hardware at all... it only depends on main cpu frequency (you only use one core...). 

 

For example, in Excel, it takes almost same time to read one cell or the entire worksheet... 

 

So, you should always reduce to the minimun these conections to read data. You should go there one time and get all the information at once. 

 

In ROBOT you should try queries and see if you can get all the information you need in one shot.

 

Regards 

Message 3 of 9

Romanich
Mentor
Mentor

Hi @Temo_Escudero ,

 

Romanich_0-1611840795719.png

 

I would definitely recommend you to watch this webinar:

https://www.youtube.com/watch?v=tYvb6IzjNmQ&list=PLY-ggSrSwbZqow_60fiqJwS69mg1nQMzk&index=9

Do you find the posts helpful? "LIKE" these posts!
Have your question been answered successfully? Click 'ACCEPT SOLUTION' button.

Roman Zhelezniak, P.Eng.

Robot Evangelist & Passionate Civil Structural Engineer

LinkedIn | Robot & Хобот | App Store for Robot
EESignature


Message 4 of 9

Stephane.kapetanovic
Mentor
Mentor

hi @Temo_Escudero ,

You should review why you’re storing all these values and determine which ones are truly necessary.

For your nodes, consider creating an internal collection or array ahead of time, for example, by using a query or a table-dump method, which is significantly faster than reading directly from the node server. This approach allows you to restrict the dataset to only the nodes you actually need. Accessing a node stored in an internal structure will always be faster than querying it repeatedly through an API connection to the node server.

Without modifying your extraction logic, you might also nest the processing of both points and edges within a single loop instead of running them separately. In the current setup, you appear to be adding up the execution time of two sequential operations, one for points and another for edges. Additionally, since finite elements share adjacent nodes, you’re making redundant API calls for the same nodes.

Finally, have you considered using a language or approach that supports parallel execution?

Best regards

see also : Speeding up process of model creation using API in Robot Structural Analysis

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to click the Accept Solution button and leave a < like !
EESignature
Message 5 of 9

Temo_Escudero
Participant
Participant

Hi @rsousa_ ... Thank you for taking the time to answer. Yes, as you suggest I must keep the the 'connections' to a minimum, now I am working on finding out how I do that. Greetings!

0 Likes
Message 6 of 9

Temo_Escudero
Participant
Participant

Hi @Romanich  thank you fot taking the time to answer. Look:

 

  • I was already using robApp.Interactive = false.
  • Watching the webinar the only suggestion that seems to apply is: use collections or whole server.
  • Other recomendations are: Use Cache (to generate geometry), use multyOperatios (to create/edit geometry), use RobApp.Interactive = false (already using).

 

Consider this small piece of code:

Dim allNodes As IRobotCollection
allNodes = Me._robApp.Project.Structure.Nodes.GetAll
Dim iNode As IRobotNode
Dim jNode as ItemNode = New ItemNode

For II = 1 To allNodes.Count
  iNode = allNodes.Get(II)  '<---- TAKES ABOUT 80% OF ALL PROCESS
  jNode.ID = iNode.Number   '      ACCORDING TO VTune.
  jNode.X  = iNode.X
  jNode.Y  = iNode.Y
  jNode.Z  = iNode.Z
Next

 

The question is: is that the right way of extracting such data?  or there is a way so I can manage to perform a 'Get all data at once' and store it in a list. Like this:

 

AllNodalInfo = allNodes.GetAllAtOnce

 

Maybe that's what I am not seeing and I am accessing to the info in the worst way. Greetings!

0 Likes
Message 7 of 9

Temo_Escudero
Participant
Participant

Hi @Stephane.kapetanovic I really appreciate you took the time to answer. Look, let's assume the code is poorly programed (which it is, specially the part to get the nodal information), the thing here is that even that, I was not expecting such execution time. And to be honest the only part I have the patience to execute is to get the finite elements.

 

In my opinion to perform the operations to read information from 69000 FEs and 45000 nodes does not worth the effor to parallelize and to change a programming language.

 

Now I am aware that reading the info in the way I am doing it seems very ineffitient.

 

Changing the approach, now is possible to read the info in like 15-20 minutes. The question is: is that the average time? there is a way of doing it in like 1 minute or less?

0 Likes
Message 8 of 9

Romanich
Mentor
Mentor

Hi @Temo_Escudero ,

 

By the way, in Excel VBA do not forget to use Application.ScreenUpdating = False in the beginning of your macro

Do you find the posts helpful? "LIKE" these posts!
Have your question been answered successfully? Click 'ACCEPT SOLUTION' button.

Roman Zhelezniak, P.Eng.

Robot Evangelist & Passionate Civil Structural Engineer

LinkedIn | Robot & Хобот | App Store for Robot
EESignature


0 Likes
Message 9 of 9

Stephane.kapetanovic
Mentor
Mentor

hi Temo_Escudero,

 

This topic appears to be outside the strict scope of API usage and is more closely related to point clouds, algorithms, and language-level performance optimization.

Since I am not familiar with the performance characteristics of your environment, and given that you are working with a language such as VBA, you will need to streamline your code carefully: disconnect anything nonessential and rely on indexing strategies with as few intermediaries as possible to handle large data volumes efficiently.

That said, you will find experienced professionals here who have solid backgrounds in developing production-grade applications and who can provide valuable guidance.

To answer your question directly: retrieving approximately 45,000 nodes takes less than two seconds on my HP ZBook (i7, SSD) with a redesigned project architecture. Adding bars, panels, and a progress bar increases the processing time by approximately one to two minutes.

By adopting a parallelized approach and properly balancing loading time with post-processing, you should be able to achieve everything your current program does in under a minute.

Architecture and methodology are just as important as raw execution speed.

Effective data management makes a decisive difference. And, as always, good code rarely emerges on the first attempt.

 

Best regards

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to click the Accept Solution button and leave a < like !
EESignature