Discussion Groups

Robot Structural Analysis

Reply
Product Support
Rafal.Gaweda
Posts: 4,990
Registered: ‎04-26-2010

Re: Export results ARSA

02-16-2012 06:48 AM in reply to: mateaus

First remark - something is wrong with cases loop if you have more than 1 case selected.

 



Rafal Gaweda
Please use plain text.
Product Support
Rafal.Gaweda
Posts: 4,990
Registered: ‎04-26-2010

Re: Export results ARSA

02-16-2012 07:59 AM in reply to: mateaus

Take a look at green code below. 

This sub should work fine.

 

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-meme 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


Next j
Point = Point + Step
Next ii

Next i

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

End Sub



Rafal Gaweda
Please use plain text.
Distinguished Contributor
mateaus
Posts: 117
Registered: ‎10-10-2011

Re: Export results ARSA

02-16-2012 08:09 AM in reply to: Rafal.Gaweda

ok thanks, do you know how to change with API the scale of results on graphic ?

 

scale

Please use plain text.
Distinguished Contributor
mateaus
Posts: 117
Registered: ‎10-10-2011

Re: Export results ARSA

02-20-2012 08:19 AM in reply to: mateaus

Bonjour,

 

Do you know how to export the reactions kz like :

 

Set BFD = BarForceServer.Value(BarNumber, UNC, Point)

Cells(Row, 7) = BFD.KZ * 0.001

 

réaction Kz

Please use plain text.
Product Support
Rafal.Gaweda
Posts: 4,990
Registered: ‎04-26-2010

Re: Export results ARSA

02-21-2012 12:00 AM in reply to: mateaus

mateaus wrote:

ok thanks, do you know how to change with API the scale of results on graphic ?

 

I am afraid it is not possible to control scale by API.

 



Rafal Gaweda
Please use plain text.
Product Support
Rafal.Gaweda
Posts: 4,990
Registered: ‎04-26-2010

Re: Export results ARSA

02-21-2012 02:55 AM in reply to: mateaus

mateaus 

 

Do you know how to export the reactions kz like :

 

Set BFD = BarForceServer.Value(BarNumber, UNC, Point)

Cells(Row, 7) = BFD.KZ * 0.001

 

This is KZ value , the one to the left from Reaction KZ checkbox shown on your screen capture

 

réaction Kz

 

Raction KZ is not available thru API. You have to calculate it by yourself \ your code.

Example below - additional code in green.

Keep in mind that results strongly depend on number of points along bar and compaxity of KZ diagram.

 

.

.

.

Step = 1# / (NumberOfPoints - 1)


Dim KZReaction() As Double
ReDim KZReaction(2)
KZReaction(1) = 0#
Dim EleLen As Double
EleLen = 0#
Dim KZAComb As Boolean
Dim KZACode As Boolean
KZACode = False
KZAComb = False
Dim CCount As Integer

If CaseCol.Get(j).Type = I_CT_CODE_COMBINATION Then
CCount = CaseCol.Get(j).Components.Count
ReDim KZReaction(CCount)

For iicomp = 1 To CCount
KZReaction(iicomp) = 0#
Next iicomp
End If

For ii = 1 To NumberOfPoints

If CaseCol.Get(j).Type = I_CT_CODE_COMBINATION Then



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 = "/" + Right(Str(Icomp), Len(Str(Icomp)) - 1)

Row = Row + 1

If ii = 1 Then
Cells(Row, 1) = barstr + OriNodeStr + CaseStr + CompStr
ElseIf ii = NumberOfPoints Then
Cells(Row, 1) = barstr + EndNodeStr + CaseStr + CompStr
Else
Cells(Row, 1) = barstr + Str(ii) + "/" + Right(Str(NumberOfPoints), Len(Str(NumberOfPoints)) - 1) + " / " + CaseStr + CompStr
End If

Set BFD = BarForceServer.ValueEx(BarNumber, UNC, Icomp, Point)
Cells(Row, 2) = BFD.FX
Cells(Row, 3) = BFD.FZ
Cells(Row, 4) = BFD.MY
' Cells(Row, 5) = BFD.KZ

KZACode = BFD.KZAvailable
If KZACode Then
EleLen = RBar.Length / (NumberOfPoints - 1)

If ii = 1 Or ii = NumberOfPoints Then EleLen = EleLen / 2
' Cells(Row, 6) = BFD.KZ * EleLen
KZReaction(Icomp) = KZReaction(Icomp) + BFD.KZ * EleLen
End If
Set BFD = Nothing
Next Icomp
End If
Else
Row = Row + 1
If ii = 1 Then
Cells(Row, 1) = barstr + OriNodeStr + CaseStr
ElseIf ii = NumberOfPoints Then
Cells(Row, 1) = barstr + EndNodeStr + CaseStr
Else
Cells(Row, 1) = barstr + Str(ii) + "/" + Right(Str(NumberOfPoints), Len(Str(NumberOfPoints)) - 1) + " / " + CaseStr
End If

Set BFD = BarForceServer.Value(BarNumber, UNC, Point)
Cells(Row, 2) = BFD.FX
Cells(Row, 3) = BFD.FZ
Cells(Row, 4) = BFD.MY
' Cells(Row, 5) = BFD.KZ
KZAComb = BFD.KZAvailable
If KZAComb Then
EleLen = RBar.Length / (NumberOfPoints - 1)

If ii = 1 Or ii = NumberOfPoints Then EleLen = EleLen / 2
' Cells(Row, 6) = BFD.KZ * EleLen
KZReaction(1) = KZReaction(1) + BFD.KZ * EleLen
End If
Set BFD = Nothing

End If
Point = Point + Step

Next ii
If KZAComb Then
Cells(Row, 7) = "KZ Reaction for bar " & Str(BarNumber) & " Case " & CaseStr
Cells(Row, 8) = KZReaction(1)
KZAComb = False
End If
If KZACode Then
For Icomp = 1 To CCount
Cells(Row - CCount + Icomp, 7) = "KZ Reaction for bar " & Str(BarNumber) & " Case " & CaseStr & " /" & Str(Icomp)
Cells(Row - CCount + Icomp, 8) = KZReaction(Icomp)
KZACode = False
Next Icomp
End If
Next j
Next i

End If
Cells(20, 8) = ""
Cells(20, 9) = ""
End Sub

 



Rafal Gaweda
Please use plain text.
Distinguished Contributor
mateaus
Posts: 117
Registered: ‎10-10-2011

Re: Export results ARSA

04-26-2012 07:10 AM in reply to: Rafal.Gaweda

Hi,

 

I would like to export results of my plate with VBA. 

 

Now I'm doing this :

 

mode d'emploi_extraction robot cas elet finis.png

 

Can you give the macro to export it in excel automatically for simple case and moving case (only composant LM2 + LM2 _ ...) together ?

Please use plain text.
Product Support
Rafal.Gaweda
Posts: 4,990
Registered: ‎04-26-2010

Re: Export results ARSA

04-27-2012 08:07 AM in reply to: mateaus

Take a look at attached xls



Rafal Gaweda
Please use plain text.
Distinguished Contributor
mateaus
Posts: 117
Registered: ‎10-10-2011

Re: Export results ARSA

04-27-2012 10:45 AM in reply to: Rafal.Gaweda

Ok good but I'm looking for results by nodes.

 

Have good something for me ?

 

Thanks

Please use plain text.
Product Support
Rafal.Gaweda
Posts: 4,990
Registered: ‎04-26-2010

Re: Export results ARSA

04-30-2012 12:09 AM in reply to: mateaus

Example attached



Rafal Gaweda
Please use plain text.