Read design results with EXCEL VBA

Hello, I’m a bit late, but I have a similar question. I found the example in the installation folder and got it working, however I would like to read the design results [107] instead of the nodes [20]. I don’t know how to adapt the example, maybe someone has an Excel file with the function?

In the folder:
C:\Program Files\SOFiSTiK\2023\SOFiSTiK 2023\interfaces\examples\vba
Check out the following files:
cdb2excel_2018_1.xlsm
sofistik_daten.bas

The first is complete template for importing data to excel and the second has the necessary structs in vba format.

You can find sofistiks code for 107 in the module_beams module in vba:

Thanks for your help, unfortunately I’m quite a beginner when it comes to vba.
In the read node example (C:\Program Files (x86)\2022\SOFiSTiK 2022\interfaces\examples\vba\read_nodes\read_nodes_64-bit.xlsm) I can paste my file path and get the node information.

I need something similar for the design results. There is no such thing in the module_beams code.
I took the working nodes module (read_nodes_64-bit.xlsm):

Option Explicit

'+============================================================================+
'| Company: SOFiSTiK AG |
'| Version: SOFiSTIK 2022 |
'+============================================================================+

'Read the nodes from CDB
Public Sub readNodes()
Dim Filename As String
Dim Index, datalen As Long
Dim row, pos As Long
Dim arr_20_0() As Variant
ReDim arr_20_0(6, 0)
Dim Destination1 As Range

'Lets clear the sheet first
tab1.Cells.Clear

'The path of the file
Filename = tab1.TextBox1.Text

'To connect to the CDB we will use
Index = sof_cdb_init(Filename, 99)
  
'Get the data from CDB
Dim data As CNODE
datalen = Len(data)

Do While sof_cdb_get(Index, 20, 0, data, datalen, pos) = 0
    row = row + 1
    pos = pos + 1
    
    'Redim the array for the output
    ReDim Preserve arr_20_0(6, row)
    
    'Copy the values to array
    arr_20_0(0, row) = data.m_NR
    arr_20_0(1, row) = data.m_INR
    arr_20_0(2, row) = data.m_KFIX
    arr_20_0(3, row) = data.m_NCOD
    arr_20_0(4, row) = data.m_XYZ(1)
    arr_20_0(5, row) = data.m_XYZ(2)
    arr_20_0(6, row) = data.m_XYZ(3)
    
    'Get the length of the data. This is very important!!!
    datalen = Len(data)
Loop

'Set the names of header row and columns
arr_20_0(0, 0) = "NR"
arr_20_0(1, 0) = "INR"
arr_20_0(2, 0) = "KFIX"
arr_20_0(3, 0) = "NCOD"
arr_20_0(4, 0) = "X"
arr_20_0(5, 0) = "Y"
arr_20_0(6, 0) = "Z"

'Output the values to range
Set Destination1 = tab1.Range("A4")
Destination1.Resize(UBound(arr_20_0, 2) + 1, UBound(arr_20_0, 1) + 1).Value = Application.Transpose(arr_20_0)

'Center the output -> this is just for better looking
tab1.Cells.HorizontalAlignment = xlCenter

'Close the CDB
Call sof_cdb_close(0)

End Sub

copied it and changed some values, but the loop is always skipped:

Option Explicit

'+============================================================================+
'| Company: SOFiSTiK AG |
'| Version: SOFiSTIK 2022 |
'+============================================================================+

'Read the designresults from CDB
Public Sub readDesignresults()
Dim Filename As String
Dim Index, datalen As Long
Dim row, pos As Long
Dim arr_107_0() As Variant
ReDim arr_107_0(40, 0)
Dim Destination1 As Range

'Lets clear the sheet first
tab1.Cells.Clear

'The path of the file
Filename = tab1.TextBox1.Text

'To connect to the CDB we will use
Index = sof_cdb_init(Filename, 99)
  
'Get the data from CDB
Dim data As CBEAM_DE0
datalen = Len(data)

Do While sof_cdb_get(Index, 107, 0, data, datalen, pos) = 0
    row = row + 1
    pos = pos + 1
    
    'Redim the array for the output
    ReDim Preserve arr_107_0(40, row)
    
    'Copy the values to array
    arr_107_0(0, row) = data.m_NR
    arr_107_0(1, row) = data.m_X
    arr_107_0(2, row) = data.m_NI
    arr_107_0(3, row) = data.m_MYI
    arr_107_0(4, row) = data.m_MZI
    arr_107_0(5, row) = data.m_SCF
    arr_107_0(6, row) = data.m_E0
    arr_107_0(7, row) = data.m_EY
    arr_107_0(8, row) = data.m_EZ
    arr_107_0(9, row) = data.m_E1
    arr_107_0(10, row) = data.m_E2
    arr_107_0(11, row) = data.m_HL
    arr_107_0(12, row) = data.m_HVM
    arr_107_0(13, row) = data.m_HX
    arr_107_0(14, row) = data.m_EDCMIN
    arr_107_0(15, row) = data.m_EDCMAX
    arr_107_0(16, row) = data.m_FCHK
    arr_107_0(17, row) = data.m_TCF
    arr_107_0(18, row) = data.m_SCN
    arr_107_0(19, row) = data.m_SCVY
    arr_107_0(20, row) = data.m_SCVZ
    arr_107_0(21, row) = data.m_SCMT
    arr_107_0(22, row) = data.m_SCMY
    arr_107_0(23, row) = data.m_SCMZ
    arr_107_0(24, row) = data.m_SCMB
    arr_107_0(25, row) = data.m_SCT2
    arr_107_0(26, row) = data.m_SCCOMB
    arr_107_0(27, row) = data.m_SCBN
    arr_107_0(28, row) = data.m_CSIGC
    arr_107_0(29, row) = data.m_CSIGT
    arr_107_0(30, row) = data.m_CTAU
    arr_107_0(31, row) = data.m_CSGV
    arr_107_0(32, row) = data.m_CSGR
    arr_107_0(33, row) = data.m_CAS
    arr_107_0(34, row) = data.m_CASL
    arr_107_0(35, row) = data.m_CCW
    arr_107_0(36, row) = data.m_CSGD
    arr_107_0(37, row) = data.m_CTAU0
    arr_107_0(38, row) = data.m_C2T
    arr_107_0(39, row) = data.m_CLASS

    
    'Get the length of the data. This is very important!!!
    datalen = Len(data)
Loop

'Set the names of header row and columns
  arr_107_0(0, 0) = "nr"
  arr_107_0(1, 0) = "X"
  arr_107_0(2, 0) = "NI"
  arr_107_0(3, 0) = "MYI"
  arr_107_0(4, 0) = "MZI"
  arr_107_0(5, 0) = "SCF"
  arr_107_0(6, 0) = "E0"
  arr_107_0(7, 0) = "EY"
  arr_107_0(8, 0) = "EZ"
  arr_107_0(9, 0) = "E1"
  arr_107_0(10, 0) = "E2"
  arr_107_0(11, 0) = "HL"
  arr_107_0(12, 0) = "HVM"
  arr_107_0(13, 0) = "HX"
  arr_107_0(14, 0) = "EDCMIN"
  arr_107_0(15, 0) = "EDCMAX"
  arr_107_0(16, 0) = "FCHK"
  arr_107_0(17, 0) = "TCF"
  arr_107_0(18, 0) = "SCN"
  arr_107_0(19, 0) = "SCVY"
  arr_107_0(20, 0) = "SCVZ"
  arr_107_0(21, 0) = "SCMT"
  arr_107_0(22, 0) = "SCMY"
  arr_107_0(23, 0) = "SCMZ"
  arr_107_0(24, 0) = "SCMB"
  arr_107_0(25, 0) = "SCT2"
  arr_107_0(26, 0) = "SCCOMB"
  arr_107_0(27, 0) = "SCBN"
  arr_107_0(28, 0) = "CSIGC"
  arr_107_0(29, 0) = "CSIGT"
  arr_107_0(30, 0) = "CTAU"
  arr_107_0(31, 0) = "CSGV"
  arr_107_0(32, 0) = "CSGR"
  arr_107_0(33, 0) = "CAS"
  arr_107_0(34, 0) = "CASL"
  arr_107_0(35, 0) = "CCW"
  arr_107_0(36, 0) = "CSGD"
  arr_107_0(37, 0) = "CTAU0"
  arr_107_0(38, 0) = "C2T"
  arr_107_0(39, 0) = "CLASS"



'Output the values to range
Set Destination1 = tab1.Range("A4")
Destination1.Resize(UBound(arr_107_0, 2) + 1, UBound(arr_107_0, 1) + 1).Value = Application.Transpose(arr_107_0)

'Center the output -> this is just for better looking
tab1.Cells.HorizontalAlignment = xlCenter

'Close the CDB
Call sof_cdb_close(0)

End Sub

  1. If you want your file to work:
    You need to pick a loadcase
    While sof_cdb_get(Index, 107, 0, data, datalen, pos) = 0
    means: loop for 107/0, you probably don’t have that key but 107/LC (replace the 0)

  2. If you want to use the prepared file cdb2excel_2018_1.xlsm just go to the sofistik ribbon:


    The necessary tools are there.

1 Like

Thank you so far. It works now and gives me the values, but somehow there are different values ​​in the database than in the report browser. I compared the moment and they are different values, only 0 and 135 are the same.

What can be the reason for this?

Just a guess by going with the screenshots:

  • Result browser: Actual forces according to the loadcase
  • cdb: Maximum design forces (i.e. capacity) :
    107/LC: BEAM_DES | Ultimate/Plastic Design results`