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: 

(API) Is there a way to get Results faster

20 REPLIES 20
Reply
Message 1 of 21
d.robin
1848 Views, 20 Replies

(API) Is there a way to get Results faster

Hi,

 

Is there a way to get Results faster thant that ? because it's very slow

 

        Public Shared Sub loadResultats(ByRef Resultats As List(Of ResultatRobotRDM))
            Try
                Resultats = New List(Of ResultatRobotRDM)

                gProjet = gRobotApplication.Project
                If gProjet.Structure.Bars.GetAll.Count > 0 Then
                    Dim gRobotNoeuDepla As Object = gProjet.Structure.Results.Nodes.Displacements
                    Dim gRobotBarForce As Object = gProjet.Structure.Results.Bars.Forces
                    Dim gRobotBarStress As Object = gProjet.Structure.Results.Bars.Stresses
                    Dim gRobotReaction As Object = gProjet.Structure.Results.Nodes.Reactions

                    Dim TousCas As Object = gProjet.Structure.Cases.GetAll

                    Dim NbTot As Integer = Current.Barres.Count '+ Current.Noeuds.Count
                    Dim Ind As Integer = 1
                    For Each iBarre As Integer In Current.Barres
                        progressPourcent(Ind * 100 \ NbTot)
                        Ind += 1
                        If CBool(gProjet.Structure.Bars.Exist(iBarre)) Then
                            Dim Barre As Object = gProjet.Structure.Bars.Get(iBarre)
                            Dim iStart As Integer = Barre.StartNode
                            Dim iFin As Integer = Barre.EndNode
                            If iStart > iFin Then
                                iStart = Barre.EndNode
                                iFin = Barre.StartNode
                            End If
                            For iNoeud As Integer = iStart To iFin
                                If CBool(gProjet.Structure.Nodes.Exist(iNoeud)) Then
                                    Dim N As Object = gProjet.Structure.Nodes.Get(iNoeud)
                                    Dim Position As Decimal
                                    If iNoeud = iStart Then
                                        Position = 0
                                    Else
                                        Position = 1 '1=100%
                                    End If
                                    For iCas As Integer = 1 To TousCas.Count
                                        Dim Cas As Object = TousCas.Get(iCas)
                                        Dim Forc As Object = gRobotBarForce.Value(iBarre, iCas, Position)
                                        Dim Constr As Object = gRobotBarStress.Value(iBarre, iCas, Position)
                                        Dim UR As Object = gRobotNoeuDepla.Value(iNoeud, iCas)
                                        Dim FM As Object = gRobotReaction.Value(iNoeud, iCas)
                                        Dim Res As New ResultatRobotRDM With {.Barre = CStr(iBarre), .Noeud = CStr(iNoeud), .Position = N.X, _
                                            .Cas = Cas.Name.Trim, _
                                            .FX_Eff = CDec(Forc.FX) / 10, .FZ_Eff = CDec(Forc.FZ / 10), _
                                            .MY_Eff = CDec(Forc.MY) / 10, _
                                            .SMin = CDec(Constr.Smin), .SMax = CDec(Constr.Smax), _
                                            .UX = CDec(UR.UX) * 1000, .UZ = CDec(UR.UZ) * 1000, _
                                            .RY = CDec(UR.RY), _
                                            .FX_Reac = CDec(FM.FX) / 10, .FZ_Reac = CDec(FM.FZ) / 10, _
                                            .MY_Reac = CDec(FM.MY) / 10}
                                        Resultats.Add(Res)
                                        FM = Nothing
                                        UR = Nothing
                                        Constr = Nothing
                                        Forc = Nothing
                                        Cas = Nothing
                                    Next
                                End If
                            Next
                            Barre = Nothing
                        End If
                    Next
                    TousCas = Nothing
                    gRobotNoeuDepla = Nothing
                    gRobotBarForce = Nothing
                    gRobotBarStress = Nothing
                    gRobotReaction = Nothing
                End If
            Catch ex As Exception
                addError(ex)
            End Try
        End Sub

20 REPLIES 20
Message 2 of 21
Rafal.Gaweda
in reply to: d.robin

Use Query mechanism

Example:

 

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

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
Message 3 of 21
d.robin
in reply to: Rafal.Gaweda

Thanks

 

I'm going to try it

Message 4 of 21
d.robin
in reply to: Rafal.Gaweda

I do not find I_RPT_BAR_ELEMENT_DIV_COUNT

 

maybe it doesn't exists on 2011 version ?

Message 5 of 21
Rafal.Gaweda
in reply to: d.robin

I_RPT_BAR_ELEMENT_DIV_COUNT = 29
Use 29 instead.
If it fails it means it does not exist in 2011.


Rafal Gaweda
Message 6 of 21
d.robin
in reply to: Rafal.Gaweda

it does not crash but nothing happend

 

is it possible to select all bars and cases ?

Message 7 of 21
Rafal.Gaweda
in reply to: d.robin

gProjet.Structure.Bars.GetAll gives you colection of all bars

 

If you mean ordinary selections, like that:

 

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 ("all") 'in french use "tous"
SelCas..AddText ("all") 'in french use "tous"

 

 

 

 

 



Rafal Gaweda
Message 8 of 21
d.robin
in reply to: Rafal.Gaweda

thanks

 

it crash on getting results, COM error

 

 

            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

            SelBar = RobApp.Project.Structure.Selections.Create(IRobotObjectType.I_OT_BAR)
            SelCas = RobApp.Project.Structure.Selections.Create(IRobotObjectType.I_OT_CASE)
            SelBar.AddText("tous")
            SelCas.AddText("tous")

            RobResQueryParams = CType(RobApp.CmpntFactory.Create(IRobotComponentType.I_CT_RESULT_QUERY_PARAMS), RobotResultQueryParams)
            RobResQueryParams.Selection.Set(IRobotObjectType.I_OT_BAR, SelBar)
            RobResQueryParams.Selection.Set(IRobotObjectType.I_OT_CASE, SelCas)
            RobResQueryParams.SetParam(CType(29, IRobotResultParamType), 11) 'I_RPT_BAR_ELEMENT_DIV_COUNT, 11)

            RobResQueryParams.ResultIds.SetSize(6)

            RobResQueryParams.ResultIds.Set(1, 165) ' I_EVT_FORCE_BAR_FX) '165
            RobResQueryParams.ResultIds.Set(2, 166) 'I_EVT_FORCE_BAR_FY) '166
            RobResQueryParams.ResultIds.Set(3, 167) 'I_EVT_FORCE_BAR_FZ) '167
            RobResQueryParams.ResultIds.Set(4, 168) ' I_EVT_FORCE_BAR_MX) '168
            RobResQueryParams.ResultIds.Set(5, 169) ' I_EVT_FORCE_BAR_MY) '169
            RobResQueryParams.ResultIds.Set(6, 170) ' I_EVT_FORCE_BAR_MZ) '170

            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 = CDbl(RobResRowSet.CurrentRow.GetValue(RobResRowSet.ResultIds.Get(5)))
                    If (min > v) Then min = v
                    If (max < v) Then max = v
                    ok = RobResRowSet.MoveNext()
                End While
            Loop While Res = IRobotResultQueryReturnType.I_RQRT_MORE_AVAILABLE

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

Message 9 of 21
Rafal.Gaweda
in reply to: d.robin

Try RobResQueryParams.SetParam(29, 11)
or maybe it crashes on "tous" ?


Rafal Gaweda
Message 10 of 21
d.robin
in reply to: Rafal.Gaweda

  RobResQueryParams.SetParam(CType(29, IRobotResultParamType), 11)

is just because I'm using vb.net project with option strict on

 

if I use it with strict off and test like you it's the same (cause runtime do the same by boxing type...)

Message 11 of 21
Rafal.Gaweda
in reply to: d.robin

So use newer robot version


Rafal Gaweda
Message 12 of 21
d.robin
in reply to: Rafal.Gaweda

lol thanks

 

any other suggestion ?

Message 13 of 21
Rafal.Gaweda
in reply to: d.robin

Get whole Bars server


Rafal Gaweda
Message 14 of 21
d.robin
in reply to: Rafal.Gaweda

can you say more about it please ?

Message 15 of 21
Rafal.Gaweda
in reply to: d.robin

Dim BS As RobotBarServer
Set BS = robapp.Project.Structure.Bars


Rafal Gaweda
Message 16 of 21
d.robin
in reply to: Rafal.Gaweda

and how do you get stresses and forces and the rest from this ?

Message 17 of 21
Rafal.Gaweda
in reply to: d.robin

It has nothing to do with results.
Getting Bars faster.


Rafal Gaweda
Message 18 of 21
d.robin
in reply to: Rafal.Gaweda

so you do not respond to my first question... 🙂

Message 19 of 21
Rafal.Gaweda
in reply to: d.robin

The answer was: use Query mechanism
You can not because you have too old Robot.
Please upgrade Robot.


Rafal Gaweda
Message 20 of 21

Hi rafal

I'm trying to test your code on my machine under RSA2014 , and i have a exception on line hilighted ( see the attechments ).

Any suggestion please.

Thank you.

 

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

Post to forums  

Autodesk Design & Make Report