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
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
I do not find I_RPT_BAR_ELEMENT_DIV_COUNT
maybe it doesn't exists on 2011 version ?
it does not crash but nothing happend
is it possible to select all bars and cases ?
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"
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)
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...)
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.