2053x
001379
2016-12-20

COM Interface in VBA | 2.1 Creating Member

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.

To be able to create this type of 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 impossible 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 with 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 mentioned above, the array including the node data is transferred using the methods PrepareModification() and FinishModification(). For numbering, the following fact is important: When a new element is to be transferred that already includes the reference numbers, 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 minor 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 case of a 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.

Completion of Member

After deleting all the materials, you can create a new material. Just as in RFEM, it is also possible here to transfer the material directly from the material library using its name. To do this, the corresponding string is entered 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 as in RFEM, it also suffices here to specify the cross‑section at the member start. 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, The exceptions are the deletion of materials and the creation of new materials. In this case, you have to use two separated blocks, since it is impossible 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 form the basis for all structural elements that can be transferred via COM. Nonlinear member releases or nodal supports, which include additional nesting, are exceptions. These elements will be explained in the following articles of this series.


Author

Mr. Günthel provides technical support for our customers.

Links
Downloads