hi @skellyRSA2023
Here is some code that should allow you to filter the results of an automatic combination by component.
Type ComponentEnvelope
MinValue As Double
MinBar As Long
MinPoint As Long
MinCase As Long
MinCaseComp As Long
MinValues(5) As Double
MaxValue As Double
MaxBar As Long
MaxPoint As Long
MaxCase As Long
MaxCaseComp As Long
MaxValues(5) As Double
End Type
Public Sub ExtractAndFilterByComponent()
Dim Robapp As RobotApplication: Set Robapp = New RobotApplication
Dim ps As RobotSelection, cs As RobotSelection
With Robapp.Project.Structure.Selections
Set ps = .Get(I_OT_BAR)
Set cs = .Get(I_OT_CASE)
End With
tb = Array(165, 166, 167, 168, 169, 170)
cnt = UBound(tb)
Dim qp As RobotResultQueryParams
Set qp = Robapp.CmpntFactory.Create(I_CT_RESULT_QUERY_PARAMS)
With qp
.SetParam I_RPT_BAR_DIV_COUNT, 2
.Selection.Set I_OT_BAR, ps
.Selection.Set I_OT_CASE, cs
.ResultIds.SetSize cnt + 1: For i = 0 To cnt: .ResultIds.Set i + 1, tb(i): Next i
End With
Dim env(5) As ComponentEnvelope
For i = 0 To 5
env(i).MinValue = 1.79769313486231E+308: env(i).MaxValue = -1.79769313486231E+308
Next i
Dim RowSet As New RobotResultRowSet, Row As RobotResultRow, Res As IRobotResultQueryReturnType
Dim ok As Boolean, v(5) As Double, p As Long, pt As Long, c As Long, cc As Long
Do
Res = Robapp.Project.Structure.Results.Query(qp, RowSet)
ok = RowSet.MoveFirst
While ok
Set Row = RowSet.CurrentRow
cc = Row.GetParam(I_RPT_LOAD_CASE_CMPNT)
Select Case cc
Case 1, 15, 21, 28, 30 ' Make your component selection here
Case Else
GoTo nextStep
End Select
p = Row.GetParam(I_RPT_BAR): pt = Row.GetParam(I_RPT_BAR_DIV_POINT): c = Row.GetParam(I_RPT_LOAD_CASE)
For i = 0 To 5
On Error Resume Next
v(i) = Row.GetValue(tb(i)): If Err.Number <> 0 Then v(i) = 0
On Error GoTo 0
Next i
For i = 0 To 5
If v(i) < env(i).MinValue Then
env(i).MinValue = v(i): env(i).MinBar = p: env(i).MinPoint = pt: env(i).MinCase = c: env(i).MinCaseComp = cc
For j = 0 To 5: env(i).MinValues(j) = v(j): Next j
End If
If v(i) > env(i).MaxValue Then
env(i).MaxValue = v(i): env(i).MaxBar = p: env(i).MaxPoint = pt: env(i).MaxCase = c: env(i).MaxCaseComp = cc
For j = 0 To 5: env(i).MaxValues(j) = v(j): Next j
End If
Next i
nextStep:
ok = RowSet.MoveNext
Wend
Loop While Res = I_RQRT_MORE_AVAILABLE
Debug.Print "Bar/Pt/Cse/Cmp " & _
Left("FX (N) ", 14) & " " & _
Left("FY (N) ", 14) & " " & _
Left("FZ (N) ", 14) & " " & _
Left("MX (Nm) ", 12) & " " & _
Left("MY (Nm) ", 12) & " " & _
Left("MZ (Nm) ", 12)
Debug.Print String(95, "-")
For i = 0 To 5
Dim minLine As String
minLine = Right(Space(4) & env(i).MinBar, 4) & "/" & _
Right(Space(2) & env(i).MinPoint, 2) & "/" & _
Right(Space(3) & env(i).MinCase, 3) & "/" & _
Right(Space(3) & env(i).MinCaseComp, 3) & " "
For j = 0 To 5
Dim minVal As String
minVal = Format(env(i).MinValues(j), "0.00"): If j = i Then minVal = minVal & "<<"
minLine = minLine & Right(Space(12) & minVal, 12) & " "
Next j
Debug.Print minLine
Dim maxLine As String
maxLine = Right(Space(4) & env(i).MaxBar, 4) & "/" & _
Right(Space(2) & env(i).MaxPoint, 2) & "/" & _
Right(Space(3) & env(i).MaxCase, 3) & "/" & _
Right(Space(3) & env(i).MaxCaseComp, 3) & " "
For j = 0 To 5
Dim maxVal As String
maxVal = Format(env(i).MaxValues(j), "0.00"): If j = i Then maxVal = maxVal & ">>"
maxLine = maxLine & Right(Space(12) & maxVal, 12) & " "
Next j
Debug.Print maxLine
Next i
End Sub
Results
Bar/Pt/Cse/Cmp FX (N) FY (N) FZ (N) MX (Nm) MY (Nm) MZ (Nm)
-----------------------------------------------------------------------------------------------
4/ 2/ 6/ 30 2539.84<< -3737.09 -124.84 -0.40 -416.19 12444.69
4/ 1/ 6/ 1 39771.27>> 69.00 -667.33 0.00 1112.15 115.00
4/ 1/ 6/ 30 2937.33 -7487.09<< -124.84 -0.40 208.01 -15615.74
4/ 1/ 6/ 1 39771.27 69.00>> -667.33 0.00 1112.15 115.00
4/ 1/ 6/ 1 39771.27 69.00 -667.33<< 0.00 1112.15 115.00
4/ 1/ 6/ 28 2984.61 12.91 7375.11>> 0.40 -15547.33 21.51
4/ 1/ 6/ 21 11338.68 -7472.59 -265.08 -0.40<< 441.72 -15591.57
4/ 1/ 6/ 15 27792.21 56.52 6953.33 0.40>> -14844.41 94.19
4/ 1/ 6/ 28 2984.61 12.91 7375.11 0.40 -15547.33<< 21.51
4/ 2/ 6/ 28 2587.12 12.91 3625.11 0.40 11953.21>> -43.03
4/ 1/ 6/ 30 2937.33 -7487.09 -124.84 -0.40 208.01 -15615.74<<
4/ 2/ 6/ 30 2539.84 -3737.09 -124.84 -0.40 -416.19 12444.69>>
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 !
