Robot Structural Analysis Forum
Welcome to Autodesk’s Robot Structural Analysis Forums. Share your knowledge, ask questions, and explore popular Robot Structural Analysis topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Robot API steel design becomes gradually slower

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
346 Views, 3 Replies

Robot API steel design becomes gradually slower

Hey,

 

I have made a simple API script in VBA that does the following in a loop.

 

 

  • Select an element
  • Assign a zero stiffness material to it (as if the element wasn't part of the structure)
  • Calculate model
  • Print utilization ratios
  • Repeat

The problem is that when I have hundreds of elements, the script becomes gradually slower for some reason. For the first 10% of the elements, it takes maybe 15 mins to print the utilization ratios, for the next 20%, it takes 30 mins and so on.

 

What could be done to have a consistent speed and not experience a gradual slowing?

 

Thank you for your help in advance!

 

Best regards,

Marcell

 

'---turn off screen refreshing and write progress in status bar
Application.ScreenUpdating = False
oldStatusBar = Application.DisplayStatusBar
Application.DisplayStatusBar = True

'---open robot from file name in excel
Dim robapp As RobotOM.RobotApplication
Set robapp = New RobotOM.RobotApplication
Dim filepath As String
filepath = Cells(5, 2)
robapp.Project.Open filepath

Dim serv As RobotBarForceServer
Set serv = robapp.Project.Structure.Results.Bars.Forces
Dim bar_del As IRobotBar

'---select bars to delete given in excel
Dim BarDelSelection As RobotSelection
Set BarDelSelection = robapp.Project.Structure.Selections.Create(I_OT_BAR)

Dim bar_del_col As RobotBarCollection

If (Cells(2, 2) <> "") Then
    BarDelSelection.FromText Cells(2, 2)

    Set bar_del_col = robapp.Project.Structure.Bars.GetMany(BarDelSelection)
Else
    If (MsgBox("No bars to delete in selection cell. Do you want to import results for all supporing nodes?", vbYesNo, "Warning") = vbYes) Then
        BarDelSelection.FromText "all"
        BarDelSelection.AddText "tous"
        Set bar_del_col = robapp.Project.Structure.Bars.GetMany(BarDelSelection)
    Else
        Set bar_del_col = Nothing
        Exit Sub
    End If
End If

'---select loadcases given in excel
Dim LSelection As RobotSelection
Set LSelection = robapp.Project.Structure.Selections.Create(I_OT_CASE)
   
Dim case_col As RobotCaseCollection
            
If (Worksheets("input").Cells(3, 2) <> "") Then
    LSelection.FromText Worksheets("input").Cells(3, 2)

    Set case_col = robapp.Project.Structure.Cases.GetMany(LSelection)
Else
    If (MsgBox("No load cases in selection cell. Do you want to import results for all loadcases?", vbYesNo, "Warning") = vbYes) Then
        LSelection.FromText "all"
        LSelection.AddText "tous"
        Set case_col = robapp.Project.Structure.Cases.GetMany(LSelection)
    Else
        Set case_col = Nothing
        Exit Sub
    End If
End If

'---add new sheet
Sheets.Add
ActiveSheet.Name = "results"
ActiveSheet.Move After:=Worksheets(Worksheets.Count)

'---select bars given in excel to print
Dim BarSelection As RobotSelection
Set BarSelection = robapp.Project.Structure.Selections.Create(I_OT_BAR)

Dim bar_col As RobotBarCollection

If (Worksheets("input").Cells(1, 2) <> "") Then
    BarSelection.FromText Worksheets("input").Cells(1, 2)
    Set bar_col = robapp.Project.Structure.Bars.GetMany(BarSelection)

Else
    If (MsgBox("No bars in selection cell. Do you want to import results for all supporing nodes?", vbYesNo, "Warning") = vbYes) Then
        BarSelection.FromText "all"
        BarSelection.AddText "tous"
        Set bar_col = robapp.Project.Structure.Bars.GetMany(BarSelection)
    Else
        Set bar_col = Nothing
        Exit Sub
    End If
End If

bar_cnt = bar_col.Count

'---write section names
Cells(1, 1) = "Bars"
For I = 1 To bar_cnt
    Cells(I + 1, 1) = bar_col.Get(I).Number
    Cells(I + 1, 2) = bar_col.Get(I).GetLabelName(I_LT_BAR_SECTION)
Next I

'---create zero stiffness material
Dim Label As RobotLabel
Dim zero_stiffness As RobotMaterialData

Set Label = robapp.Project.Structure.labels.Create(I_LT_BAR_MATERIAL, "no_stiffness")
Set zero_stiffness = Label.Data
zero_stiffness.Type = IRobotMaterialType.I_MT_STEEL
zero_stiffness.E = 0.0001
zero_stiffness.NU = 0.3
zero_stiffness.RO = 0.0001
zero_stiffness.Kirchoff = 0.0001
zero_stiffness.SaveToDBase
robapp.Project.Structure.labels.Store Label

'---for code check of bars
Dim RDMServer As IRDimServer
Set RDMServer = robapp.Kernel.GetExtension("RDimServer")
RDMServer.Mode = I_DSM_STEEL

Dim RDmEngine As IRDimCalcEngine
Set RDmEngine = RDMServer.CalculEngine

'--dim
Dim bar As IRobotBar
Dim cas As IRobotCase

'---code check of bars
'the part below is optional, use it if you want to set calculation parameters by the code

Dim RDmCalPar As IRDimCalcParam
Dim RDmCalCnf As IRDimCalcConf

Set RDmCalPar = RDmEngine.GetCalcParam
Set RDmCalCnf = RDmEngine.GetCalcConf

Dim RdmStream As IRDimStream 'Data stream for setting parameters
Set RdmStream = RDMServer.Connection.GetStream
RdmStream.Clear

Dim RDmDetRes As IRDimDetailedRes
Dim RDMAllRes As IRDimAllRes

'---main for loop over bars to delete
For i_model = 1 To bar_del_col.Count  

    '---assign zero stiffness material to bars, refresh view and calc
    Set bar_del = bar_del_col.Get(i_model)

    original_material = bar_del.GetLabelName(I_LT_MATERIAL)
    bar_del.SetLabel I_LT_MATERIAL, "no_stiffness"

    robapp.Project.CalcEngine.Calculate

        '---for loop over bars to get info
        For I = 1 To bar_col.Count
            
            Set bar = bar_col.Get(I)

            '---for loop over load cases
            For j = 1 To case_col.Count
                
                Set cas = case_col.Get(j)

                    'Calculate results for all sections
                    RdmStream.WriteText (Str(bar.Number)) 'member(s) selection
                    RDmCalPar.SetObjsList I_DCPVT_MEMBERS_VERIF, RdmStream 'members verification
                    RDmCalPar.SetLimitState I_DCPLST_ULTIMATE, 1 'Set Limit State
                    RdmStream.Clear

                    RdmStream.WriteText (Str(cas.Number)) 'Set Load Case(s)
                    RDmCalPar.SetLoadsList RdmStream
                    RDmEngine.SetCalcConf RDmCalCnf
                    RDmEngine.SetCalcParam RDmCalPar

                    'end of calclulation parameter settings
                    RDmEngine.Solve Nothing

                    Set RDMAllRes = RDmEngine.Results
                    Set RDmDetRes = RDMAllRes.Get(bar.Number)

                   '---print profiles and utilizations
                    Cells(1, i_model + 3) = bar_del.Number
                    Cells(I + 1, i_model + 3) = Round(RDmDetRes.Ratio, 2)

                    'Set Data = Nothing

                Set cas = Nothing

            Next j

            'Set node = Nothing

        Next I

    '---set original material back
    bar_del.SetLabel I_LT_MATERIAL, original_material

Next i_model

'---max utilization
For I = 1 To bar_cnt

Cells(1, 3) = "u_max"
Cells(I + 1, 3) = WorksheetFunction.Max(Range(Cells(I + 1, 4), Cells(I + 1, bar_del_col.Count + 4)))

Next I

Range("1:1").Font.FontStyle = "Bold"

'---turn on screen refreshing
Application.StatusBar = False
Application.DisplayStatusBar = oldStatusBar
Application.ScreenUpdating = True

Set robapp = Nothing

 

3 REPLIES 3
Message 2 of 4
Romanich
in reply to: Anonymous

Hi @Anonymous,

I would recommend to add

robapp.Interactive = False 

'your code here

robapp.Interactive = True

 

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

Roman Zhelezniak

Robot Evangelist & Passionate Civil Structural Engineer

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


Message 3 of 4
Anonymous
in reply to: Romanich

Hey @Romanich,

 

Thanks for the suggestion!

I've added your code to my script and tested the speed, but unfortunately the same problem arises. Below is a table that shows the required computation time. In the beginning, it takes only around 10 mins to complete 10% but later it takes 30 mins.

 

10%22-05-2018 14:29
20%22-05-2018 14:38
30%22-05-2018 14:55
40%22-05-2018 15:18
50%22-05-2018 15:47
60%22-05-2018 16:26
Message 4 of 4
Anonymous
in reply to: Anonymous

Hey,

 

I was wondering if anyone had any ideas regarding this issue?

 

I believe API is extremely useful to run a lot of automated analyses in Robot, but unfortunately if the analyses become gradually slower as the script runs, the whole purpose is defeated.

 

Thank you for any help or suggestion!

 

Best regards,

Marcell

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report