COM Interface in VBA | 4.1 Frame Optimization
Part 4.1 and 4.2 of this article series describes the optimization of a frame using the RF‑/STEEL EC3 add-on module. The fifth part explains how to link the module and get the relevant members. The elements already explained in the previous parts are not described again.
Filtering Relevant Members
The aim is to only transfer the members of a certain cross‑section to the RF‑/STEEL EC3 design. In the following example, all members with the IPE 300 cross‑section should be filtered. For this, it is necessary to get all cross‑sections from the main program first:
' Create a string of a desired cross‑section
Dim crsc_desc As String
crsc_desc = "IPE 300"
' Get all cross-sections from RFEM
Dim crscs() As RFEM5.CrossSection
crscs = iModelData.GetCrossSections
' Lopp over all cross-sections
Dim crsc_no As Long
crsc_no = -1
Dim i As Long
For i = 0 To UBound(crscs, 1)
' If the cross-section description is right, save the cross-section number
If InStr(LCase(crscs(i).Description), LCase(crsc_desc)) > 0 Then
crsc_no = crscs(i).No
' Quit the program if the desired cross-section was not found
If crsc_no = -1 Then
Err.Raise 513, "Get cross-section number", "No cross-section with "" " & crsc_desc & " "" within its description found!"
The cross‑section description should be synchronised as generally as possible. For this, the cross‑section description as well as the string to be searched is set to lower‑case letters via ‘LCase’ first, and then the string is searched for in the cross‑section description. If no suitable cross‑section is found, the cross‑section number remains at −1, which can then be requested and acknowledged by an abort.
After this step, the cross‑section number is known and the members with this cross‑section number can be searched for. Only the member with this cross‑section at the member start and the end should be adopted:
' Create string for the list of members and set it to zero
Dim mems_str As String
mems_str = vbanullstr
' Get all members from RFEM
Dim mems() As RFEM5.Member
mems = iModelData.GetMembers
' Lopp over all members
For i = 0 To UBound(mems, 1)
' If a member has this cross-section number at the start and the end,
' then take this number in the string
If mems(i).EndCrossSectionNo = crsc_no Then
If mems(i).EndCrossSectionNo = mems(i).StartCrossSectionNo Then
mems_str = mems_str & mems(i).No & ","
' Quit the program if no member was found
If mems_str = vbanullstr Then
Err.Raise 514, "Get members", "No member with cross-section "" " & crsc_desc & " "" found!"
Getting Add-on Module Interface
The link to a module is exactly the same as the link to RFEM or RSTAB. The only difference is that there is no difference between opening an already open instance or opening a new instance, since there is always one already open instance:
' Get interface for the module
Dim iStec3 As STEEL_EC3.Module
Set iStec3 = iModel.GetModule("STEEL_EC3")
Next, all existing module cases are removed:
' Get number of existing module cases
Dim count As Long
count = iStec3.moGetCaseCount
' If there are any cases, always delete the first one in the table
If count > 0 Then
For i = 0 To count - 1
iStec3.moDeleteCase i, AT_INDEX
Now, you can create the desired case and enter the member to be designed by using the previously created string.
' Create the 'Optimization' module case
Dim iStec3Case As STEEL_EC3.ICase
Set iStec3Case = iStec3.moSetCase(1, "Optimization")
' Set members for design
Last but not least, you can enter the desired load combinations:
' Set load combinations
Dim iStec3_uls_loads(0 To 2) As STEEL_EC3.ULS_LOAD
iStec3_uls_loads(0).DesignSituation = DS_FUNDAMENTAL
iStec3_uls_loads(0).No = 1
iStec3_uls_loads(0).Type = ILOAD_GROUP
iStec3_uls_loads(1).DesignSituation = DS_FUNDAMENTAL
iStec3_uls_loads(1).No = 2
iStec3_uls_loads(1).Type = ILOAD_GROUP
iStec3_uls_loads(2).DesignSituation = DS_FUNDAMENTAL
iStec3_uls_loads(2).No = 3
iStec3_uls_loads(2).Type = ILOAD_GROUP
Summary and Overview
The procedures described in this article can be used for all modules that can be controlled by COM. The source code and the Excel file help so you can better understand the subject matter. In my next article, I would like to delve deeper into this matter and explain the link between the elements in the module and in the main program.
Do you have any questions or need advice?
Contact us via e-mail, chat or forum. Find also various suggested solutions and useful tips on our FAQ page.
Structural engineering software for finite element analysis (FEA) of planar and spatial structural systems consisting of plates, walls, shells, members (beams), solids and contact elements
Design of steel members according to Eurocode 3
Programmable interface (API) based on the COM technology