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: 

Export results ARSA via API

74 REPLIES 74
SOLVED
Reply
Message 1 of 75
mateaus
5781 Views, 74 Replies

Export results ARSA via API

Hi,

 

I would like to export the results of efforts with VBA in excel files like in the video attached.

 

Can you help me ?

 

Export result

74 REPLIES 74
Message 2 of 75
Rafal.Gaweda
in reply to: mateaus

Upload the mentioned movie



Rafal Gaweda
Message 3 of 75
mateaus
in reply to: Rafal.Gaweda

It's on the link

Message 4 of 75
Rafal.Gaweda
in reply to: mateaus

Thanks.

Not possible to save csv from table by API. So you have to import these results to Excel then save xls file(s).



Rafal Gaweda
Message 5 of 75
mateaus
in reply to: Rafal.Gaweda

Ok, but is there a way to export results by API ?

Message 6 of 75
Rafal.Gaweda
in reply to: mateaus


Ok, but is there a way to export results by API ?


Yes, of course.

I will write you sample code.



Rafal Gaweda
Message 7 of 75
mateaus
in reply to: Rafal.Gaweda

Hi,

 

Could you send me an example to have list of efforts (Fx Fz My) with API VBA ?

Message 8 of 75
Rafal.Gaweda
in reply to: mateaus

xls file with example of table with internal forces attached.



Rafal Gaweda
Message 9 of 75
mateaus
in reply to: Rafal.Gaweda

Ok thank you,

 

I try it and it works but we have to select the bars before in the model. I will search by myself how to make it automaticaly and if I don't succeed I'll ask you one more time.

 

Just an Question. It's slow, do I need a lot of RAM to turn it faster ?

 

My System :

 

Windows XP Professionnel 2002 SP3

Intel(R) Xeon(R) CPU

W3505 @ 2.53GHz

2.53 GHz, 2.99 Go de RAM

 

Carte Graphique :

 

NVIDIA Quadro FX 580

Message 10 of 75
Rafal.Gaweda
in reply to: mateaus

 

 I will search by myself how to make it automaticaly 

 

What do you mean by that ? 

 

Just an Question. It's slow, do I need a lot of RAM to turn it faster ?

 

No, it does not depend on RAM.

I will check the code to accelerate it - if possible.



Rafal Gaweda
Message 11 of 75
mateaus
in reply to: Rafal.Gaweda

 I will search by myself how to make it automaticaly 

 

What do you mean by that ? 

 

To select automatically all the bars.

Message 12 of 75
Rafal.Gaweda
in reply to: mateaus


@mateaus wrote:

 I will search by myself how to make it automaticaly 

 

What do you mean by that ? 

 

To select automatically all the bars.


If you do not select any bar it will ask you whether to select ALL of them or stop macro.

 

or replace this section :

 

Set RSelection = RobApp.Project.Structure.Selections.Get(I_OT_BAR)
Dim BarCol As RobotBarCollection
Set BarCol = RobApp.Project.Structure.Bars.GetMany(RSelection)


If (BarCol.Count = 0) Then
If (MsgBox("No bars selected in Robot. Do you want to import results for all bars?", vbYesNo, "Warning") = vbOK) Then
RSelection.FromText "all"
RSelection.AddText "tous"
Set BarCol = RobApp.Project.Structure.Bars.GetMany(RSelection)
Else
Set BarCol = Nothing
Exit Sub
End If
End If

 

by

 

Dim BarCol As RobotBarCollection
Set BarCol = RobApp.Project.Structure.Bars.GetAll

 

 

 

I am attaching updated macro.

- Faster

- You may specify number of points along bar in it (2 as a default for begining and end only)



Rafal Gaweda
Message 13 of 75
mateaus
in reply to: Rafal.Gaweda

Ok but I don't know why but if I select a bar it give me the result of the bar selected before and I have to demand a second time to have the good results for the bars selected.

Message 14 of 75
Rafal.Gaweda
in reply to: mateaus

Small correction in attached file.

 

It may happen that somehow the selection in "not confirmed" in Robot. Try to activate Bar selection filed (combo) on top of Robot on Selection toolbar (click inside it) then "confirm selection" by pressing Enter or Tab.



Rafal Gaweda
Message 15 of 75
mateaus
in reply to: Rafal.Gaweda

Ok but my goal at the end is not to have to manipulate the program Robot and only use the macro VBA in excel. Is there another solution ?

Message 16 of 75
Rafal.Gaweda
in reply to: mateaus

Do you mean, for example, writing selection fo bar(s) , case(s) in Excell and not to use selection from Robot? There is no problem with it. Please write down what is the workflow in your mind.



Rafal Gaweda
Message 17 of 75
mateaus
in reply to: Rafal.Gaweda

I have already modify the macro to demand bar(s) , case(s) in Excell. But I have to run the macro twice to have the good selection. I would like to do it in one time without using Robot.

Message 18 of 75
Rafal.Gaweda
in reply to: mateaus

PLease attach your macro.



Rafal Gaweda
Message 19 of 75
Rafal.Gaweda
in reply to: Rafal.Gaweda

My macro where the selections are read from xls file attached.



Rafal Gaweda
Message 20 of 75
mateaus
in reply to: Rafal.Gaweda

Hi, I've modified the macro to have results with an other order :

 

1 - Number bar

2 - Number node

2 - Cases

 

For example

 

1 / 1 / 101  Fx Fz My

1 / 1 / 102  Fx Fz My

1 / 2 / 101  Fx Fz My

1 / 2 / 102  Fx Fz My

 

But it's not exporting the good efforts

 

Would you mind correct it ?

 

Sub extraction_resultats_cas()

Range("A13", "F25000").Clear
Range("B5").Clear

Set RobApp = New RobotApplication

If Not RobApp.Visible Then
    Set RobApp = Nothing
    MsgBox "Open Robot and load Model", vbOKOnly, "ERROR"
    Exit Sub
Else
    If (RobApp.Project.Type <> I_PT_FRAME_3D) And (RobApp.Project.Type <> I_PT_SHELL) Then
        MsgBox "Structure Type should be FRAME 3D or SHELL", vbOKOnly, "ERROR"
        Exit Sub
    End If
    Cells(5, 1) = "Project"
    Cells(5, 2) = RobApp.Project.Name

'selection des barres

'If CheckBox1 = True Then

'Dim BarCol As RobotBarCollection
'Set BarCol = RobApp.Project.Structure.Bars.GetAll

'Else

    Dim RSelection As RobotSelection
    Set RSelection = RobApp.Project.Structure.Selections.Get(I_OT_BAR)
    Dim BarCol As RobotBarCollection
    Set BarCol = RobApp.Project.Structure.Bars.GetMany(RSelection)
    Dim num_bar As String
    
'   If (BarCol.Count = 0) Then   c'est un test de selection du modele
'       If (MsgBox("No bars selected in Robot. Do you want to import results for all bars?", vbYesNo, "Warning") = vbYes) Then
num_bar = Cells(8, 2)
    If num_bar = "" Then
        If (MsgBox("Pas de numéro de barres indiqué ! Voulez-vous selectionner toutes les barres?", vbYesNo, "Warning") = vbYes) Then
            RSelection.FromText "all"
            RSelection.AddText "tous"
            Set BarCol = RobApp.Project.Structure.Bars.GetMany(RSelection)
        Else
            Set BarCol = Nothing
            Exit Sub
        End If
    ' ajout condition pour rentrer soi-même les numéros de barres
    Else
    RSelection.FromText num_bar
    Set BarCol = RobApp.Project.Structure.Bars.GetMany(RSelection)
    End If

'End If

    
    Set RSelection = RobApp.Project.Structure.Selections.Get(I_OT_CASE)
    Dim CaseCol As RobotCaseCollection
    Set CaseCol = RobApp.Project.Structure.Cases.GetMany(RSelection)
    Dim num_cas As String
    
 num_cas = Cells(9, 2)
    
'    If (CaseCol.Count = 0) Then
    If num_cas = "" Then
        If (MsgBox("Pas de cas ou combinaisons indiqué ! Voulez-vous importer les résultats de tous les cas ?", vbYesNo, "Warning") = vbYes) Then
            RSelection.FromText "all"
            RSelection.AddText "tous"
            Set CaseCol = RobApp.Project.Structure.Cases.GetMany(RSelection)
        Else
            Set CaseCol = Nothing
            Exit Sub
        End If
    Else
    RSelection.FromText num_cas
    Set CaseCol = RobApp.Project.Structure.Cases.GetMany(RSelection)
    End If
    
    Cells(9, 2) = RSelection.ToText
    
    NumberOfPoints = Int(Cells(10, 2).Value)
    
    If (NumberOfPoints < 2) Then
        MsgBox "Number of points along the bar must be greater or equal to 2", vbOKOnly, "Error"
        Exit Sub
    End If
    
'Sleep 10000
    
    Row = 12
'    Cells(Row, 1) = "Barre"
'    Cells(Row, 2) = "Noeud"
'    Cells(Row, 3) = "Cas (/ Composante)"
'
'     Cells(Row, 4) = "FX [kN]"
'     Cells(Row, 5) = "FZ [kN]"
'     Cells(Row, 6) = "MY [kN.m]"
     
     Cells(19, 9) = "Progression"
     
 For i = 1 To BarCol.Count
     Cells(20, 9) = Str(i) + " / " + Str(BarCol.Count)

     
     Dim RBar As RobotBar
     Set RBar = BarCol.Get(i)
     
     BarNumber = RBar.Number
     BarStr = Str(BarNumber)
     OriNodeStr = Str(RBar.StartNode)
     EndNodeStr = Str(RBar.EndNode)
     
     
     
     Dim BFD As RobotBarForceData
     Dim Icomp As Integer
     
     Dim BarForceServer As RobotBarForceServer
     Set BarForceServer = RobApp.Project.Structure.Results.Bars.Forces
     
     Dim Point As Double
     Dim Step As Double
     
     Point = 0#
     Step = 1# / (NumberOfPoints - 1)
     
For ii = 1 To NumberOfPoints

    For j = 1 To CaseCol.Count
        AT = CaseCol.Get(j).AnalizeType
     
        If AT <> I_CAT_COMB_CODE _
            And AT <> I_CAT_COMB _
            And AT <> I_CAT_COMB_NONLINEAR _
            And AT <> I_CAT_STATIC_LINEAR _
            And AT <> I_CAT_STATIC_NONLINEAR Then
                MsgBox "This macro works only for simple load cases, combinations and automatic combinations", vbOKOnly, "Error"
                Exit Sub
        End If
     
     UNC = CaseCol.Get(j).Number
     CaseStr = Str(UNC)
     If CaseCol.Get(j).Type = I_CT_CODE_COMBINATION Then  ' pour les combinaisons
          
          Dim CCount As Integer
          CCount = CaseCol.Get(j).Components.Count
          Dim StrCC As String
          StrCC = Str(CCount)
          
          If InStr(CaseCol.Get(j).Name, "+") <> 4 And InStr(CaseCol.Get(j).Name, "-") <> 4 And InStr(CaseCol.Get(j).Name, "+") <> 8 And InStr(CaseCol.Get(j).Name, "-") <> 8 Then
            For Icomp = 1 To CCount
                
                CompStr = " / " + Str(Icomp)
  
                    Row = Row + 1
          
                    If ii = 1 Then
                        Cells(Row, 1) = BarStr
                        Cells(Row, 2) = OriNodeStr
                        Cells(Row, 3) = CaseStr + CompStr
                    ElseIf ii = NumberOfPoints Then
                        Cells(Row, 1) = BarStr
                        Cells(Row, 2) = EndNodeStr
                        Cells(Row, 3) = CaseStr + CompStr
                    Else
                       Cells(Row, 1) = BarStr + Str(ii) + " /" + Str(NumberOfPoints) + " / " + CaseStr + CompStr
                     End If

                    Set BFD = BarForceServer.ValueEx(BarNumber, UNC, Icomp, Point)
         Cells(Row, 4) = BFD.FX * 0.001
         Cells(Row, 5) = BFD.FZ * 0.001
         Cells(Row, 6) = BFD.MY * 0.001

                    Set BFD = Nothing
          Next Icomp
          End If
     Else                                        ' pour les cas simples
         Row = Row + 1
         If ii = 1 Then
                        Cells(Row, 1) = BarStr
                        Cells(Row, 2) = OriNodeStr
                        Cells(Row, 3) = CaseStr
         ElseIf ii = NumberOfPoints Then
                        Cells(Row, 1) = BarStr
                        Cells(Row, 2) = EndNodeStr
                        Cells(Row, 3) = CaseStr
         Else
            Cells(Row, 1) = BarStr
            Cells(Row, 2) = Str(ii) + " /" + Str(NumberOfPoints)
            Cells(Row, 3) = CaseStr

         End If
         
         Set BFD = BarForceServer.Value(BarNumber, UNC, Point)
         Cells(Row, 4) = BFD.FX * 0.001
         Cells(Row, 5) = BFD.FZ * 0.001
         Cells(Row, 6) = BFD.MY * 0.001
         
         Set BFD = Nothing
         
     End If
     Point = Point + Step
      
      Next j
 Next ii

Next i
     
End If
Cells(19, 9) = ""
Cells(20, 9) = ""

End Sub

 

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

Post to forums  

Autodesk Design & Make Report