COM Interface in VBA | 2.1 Creating Member

Technical Article

The first part of the article series about the COM interface described opening and creating a model in RFEM. The second part explains creating and modifying elements on an example of a member. The elements described in Part 1 will not be explained here again.

Basics

A member in RFEM consists of several elements that are more or less dependent on each other. If one of these elements is missing, the member cannot be created. The following structure has to be respected.

Figure 01 - Element Structure of Member

In order to be able to create such an element, you have to get the interface for structural data:

' Get interface for model data.
Dim iModelData As iModelData
Set iModelData = iModel.GetModelData()

This interface allows you to finally transfer the data to RFEM.

Editing Mode

Once the data in RFEM are to be modified or created, RFEM has to be switched to the editing mode. For example, it is not possible to perform any calculations in this mode, and the transferred data are only available after exiting the mode. It is necessary to use the PrepareModification() method to switch to the editing mode and FinishModification() to leave the mode:

' Transfer elements to editing mode.
iModelData.PrepareModification
' ...
iModelData.FinishModification

Creating Elements

The aim is to create a member of the cross‑section IPE 100 and Structural Steel S235 from Point P0(0,0,0) to Point P1(1,0,0). First, it is necessary to create nodes. In the following example, an array is used, as it represents the highest flexibility for further program modifications:

' Create nodes.
Dim nodeList (0 To 1) As RFEM5.Node
nodeList(0).RefObjectNo = 0
nodeList(0).No = 1
nodeList(0).X = 0#
nodeList(0).Y = 0#
nodeList(0).Z = 0#

nodeList(1).RefObjectNo = 0
nodeList(1).No = 2
nodeList(1).X = 1#
nodeList(1).Y = 0#
nodeList(1).Z = 0#

iModelData.PrepareModification
iModelData.SetNodes nodeList
iModelData.FinishModification

As already mentioned above, the array including the node data is transferred by the methods PrepareModification() and FinishModification(). For numbering, the following fact is important: When a new element is to be transferred which already includes the reference numbers, then the existing elements are not overwritten but the element is added at the end of the list. If you enter a zero, the element is automatically set to the next free location.

The process of creating lines is similar, with the small difference of referring to nodes, of course. The node list is transferred as a string exactly as in RFEM:

' Create lines.
Dim lineList(0 To 0) As RFEM5.Line
lineList(0).nodeList = "1,2"
lineList(0).Type = LineType.PolylineType

' Transfer elements to editing mode.
iModelData.PrepareModification
iModelData.SetLines lineList
iModelData.FinishModification

Modifying Elements

To create a cross‑section, it is necessary to create a material first. In a new RFEM model, the materials from the model created previously are always used first. In order to ensure that the relevant material is used, you have to delete or change all existing materials. Deleting all existing materials and creating a new material is the easiest way in this case. In contrast to creating new elements, the interface of the individual elements has to be activated in the case of deletion or modification. The steps are as follows:

' Get number of existing materials.
Dim num As Integer
num = iModelData.GetMaterialCount

' Loop over existing materials.
iModelData.PrepareModification
Dim i As Integer
For i = 0 To num - 1
' Get interface to material.
Dim iMat As RFEM5.IMaterial
Set iMat = iModelData.GetMaterial(i, AtIndex)
' Delete material.
iMat.Delete
Next i
iModelData.FinishModification

You can get the interface of a material either via the relevant material number (AtNo) or via the index in the list of all materials. In contrast to the material number, the index starts at zero and has no gaps.

Finishing Member

After deleting all the materials, you can create a new material. Just like in RFEM, it is also possible here to directly transfer the material from the material library by means of its name. For this, the corresponding string is entered by using the TextID property (for more details, see RF‑COM 5.chm in SDK):

' Create new material from material library.
Dim mats(0 To 0) As RFEM5.Material
mats(0).TextID = "NameID|Steel S 235@TypeID|STEEL@StandardID|DIN EN 1993-1-1-10"
mats(0).No = 1

' Transfer elements to editing mode.
iModelData.PrepareModification
iModelData.SetMaterials mats
iModelData.FinishModification

A cross‑section is created in the same way as the material. In addition, the material number is specified:

' Create new cross‑section from library.
Dim crs(0 To 0) As RFEM5.CrossSection
crs(0).TextID = "IPE 100"
crs(0).MaterialNo = 1
crs(0).No = 1

' Transfer elements to editing mode.
iModelData.PrepareModification
iModelData.SetCrossSections crs
iModelData.FinishModification

Since all the elements of the member have been created, the member can be transferred now:

' Create new member.
Dim mems(0 To 0) As RFEM5.Member
mems(0).LineNo = 1
mems(0).StartCrossSectionNo = 1
mems(0).No = 1

' Transfer elements to editing mode.
iModelData.PrepareModification
iModelData.SetMembers mems
iModelData.FinishModification

Just like in RFEM, it is also sufficient here to specify the cross‑section at the member start and it is not necessary to create a member end release as this is automatically assumed to be rigid.

Optimization

So far, the editing mode has been retrieved for each element individually. To increase the data processing speed, you can transfer all the elements within one editing mode, except for deleting materials and creating a new material. In this case, you have to use two separated blocks as it is not possible to delete and create elements within one block:

' Delete elements in editing mode.
iModelData.PrepareModification
Dim i As Integer
For i = 0 To num - 1
' Get interface to material.
Dim iMat As RFEM5.IMaterial
Set iMat = iModelData.GetMaterial (i, AtIndex)
' Delete material.
iMat.Delete
Next i
iModelData.FinishModification

' Transfer elements to editing mode.
iModelData.PrepareModification

iModelData.SetNodes nodeList
iModelData.SetLines lineList
iModelData.SetMaterials mats
iModelData.SetCrossSections crs
iModelData.SetMembers mems

iModelData.FinishModification

Summary and Overview

The procedures explained in this article are the basis for all structural elements that can be transferred via COM. An exception is nonlinear member releases or nodal supports which include additional nesting. These elements will be explained in the following articles of this series.

Downloads

Links

Contact us

Contact to Dlubal

Do you have any questions or need advice?
Contact us or find various suggested solutions and useful tips on our FAQ page.

+49 9673 9203 0

info@dlubal.com

RFEM Main Program
RFEM 5.xx

Main Program

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