Result at multiple points along bar API

Result at multiple points along bar API

Anonymous
Not applicable
451 Views
1 Reply
Message 1 of 2

Result at multiple points along bar API

Anonymous
Not applicable

Hi,

 

I'm trying to extract max tension / compression from all bars in a large lattice structure (a transmission tower) with Robot API. Result Connect provide me with all the functionality I need but is way too slow, thus I need my own solution. 

 

My question is if there is any method / property of IRobotBarForceServer that allow me to extract Fx-values at several Points along a bar without having to hit the object multiple times (speed is an issue in my case)?

  

My code is shown below.

 

 

Thanks,

Henrik Andersson

 

 

----------------------------

Sub Rbt_import_lasterNY(lfcell, elcell, utmaxfcell, utminfcell)
    Dim elnr() As Variant
    Dim i As Variant
    Dim j As Variant
    Dim k As Variant
    Dim ind1 As Boolean
    Dim robapp As IRobotApplication
    Set robapp = New RobotApplication
    Dim force_serv As IRobotBarForceServer
    Set force_serv = robapp.Project.Structure.Results.Bars.Forces
    Dim data1 As IRobotBarForceData
    Dim data2 As IRobotBarForceData
    Dim res_fxmax As Double   'Double
    Dim res_fxmin As Double   'Double
   
    ' Create vector with elements
    Range(elcell).Select
    elnr = Range(Selection, Selection.End(xlDown)).Value
   
    ' Create vector with load combinations
    k = 0
    Dim lf As Variant
    Dim lastvek() As Integer
    For Each i In Split(Trim(Range(lfcell).Text), " ")
        If InStr(i, "to") <> 0 Then
            lf = Split(i, "to")
            For j = CInt(lf(0)) To CInt(lf(1))
                ReDim Preserve lastvek(k)
                lastvek(k) = CInt(j)
                k = k + 1
            Next j
        Else
            ReDim Preserve lastvek(k)
            lastvek(k) = CInt(i)
            k = k + 1
        End If
    Next i
   
    For Each i In elnr
        ind1 = False
        For Each j In lastvek
            Set data1 = force_serv.Value(i, j, 0)
            Set data2 = force_serv.Value(i, j, 1)
               
            If Not ind1 Then
                res_fxmax = Application.WorksheetFunction.Max(data1.FX, data2.FX)
                res_fxmin = Application.WorksheetFunction.Min(data1.FX, data2.FX)
                ind1 = True
            Else
                res_fxmax = Application.WorksheetFunction.Max(data1.FX, data2.FX, res_fxmax)
                res_fxmin = Application.WorksheetFunction.Min(data1.FX, data2.FX, res_fxmin)
            End If
            ' Free variable
            Set data1 = Nothing
            Set data2 = Nothing
        Next j
        ' Free variable
        Range(utmaxfcell).Offset(k, 0).Value = res_fxmax / 1000
        Range(utminfcell).Offset(k, 0).Value = res_fxmin / 1000
        k = k + 1
    Next i
   
    ' Free variable
    Set force_serv = Nothing
    Set robapp = Nothing
End Sub

0 Likes
452 Views
1 Reply
Reply (1)
Message 2 of 2

rsousa_
Advocate
Advocate
0 Likes