Dim iApp As RFEM5.ApplicationSet iApp = GetObject(, "RFEM5.Application")Then, the error handler is started and the license is locked:' Error HandlerOn Error GoTo e' COM license and program access is locked.iApp.LockLicense
We recommend starting the handler before locking the license; otherwise, RFEM remains locked in case of an error and can only be closed using Task Manager. Since the interface is now ready to be applied, you can get the interface for the model:
' Get interface for first model.Dim iModel As RFEM5.modelIf iApp.GetModelCount > 0 Then Set iModel = iApp.GetModel(0)Else Err.Raise vbObjectError, "LoadModel()", "iApp.GetModelCount < 1"End If
For better error handling, you can check whether the model is actually available (GetModelCount, in this case) before retrieving the model. Even in the case of other interfaces, such as the interface for load cases or loads, you can indicate errors in a better way.
Create Nodal Supports
A single‑span beam should be created, and, because the member is along the x‑axis, the x,y,z translation and the rotation around the x- and z‑axis have to be locked on Node 1 as well. The support on Node 2 is similar to the first one up to the free translation in the x‑direction. Before creating the nodal supports, it is still necessary to retrieve the interface for the model data. When defining the support, you should make sure that in the case of degrees of freedom, a number greater than or equal to 0 is equalized with the release by using a spring constant. Here, the SI units are also used; that is, N/m or N/rad:
' Get interface for model data.Dim iModelData As RFEM5.iModelDataSet iModelData = iModel.GetModelData()
' Create nodal supports.Dim nodsups(0 To 1) As RFEM5.NodalSupportnodsups(0).No = 1nodsups(0).nodeList = "1"nodsups(0).RestraintConstantX = -1nodsups(0).RestraintConstantY = 0#nodsups(0).RestraintConstantZ = -1nodsups(0).SupportConstantX = -1nodsups(0).SupportConstantY = -1nodsups(0).SupportConstantZ = -1
nodsups(1).No = 2nodsups(1).nodeList = "2"nodsups(1).RestraintConstantX = -1nodsups(1).RestraintConstantY = 0#nodsups(1).RestraintConstantZ = -1nodsups(1).SupportConstantX = 0#nodsups(1).SupportConstantY = -1nodsups(1).SupportConstantZ = -1
If any problems occur, they may be caused by the wrong data type. If double is required, the integer entry may cause errors. Thus, it is necessary to add a hash key after the integer value, so that it is used as a double value.
Of course, the nodal support must then be transferred to the editing mode again (PrepareModification / FinishModification):
' Transfer nodal supports.iModelData.PrepareModificationiModelData.SetNodalSupports nodsupsiModelData.FinishModification
Create Load Cases
In order to create loads, you have to define load cases first, exactly as in RFEM. When programming, the load cases are created and transferred first, and only afterwards can the loads be transferred by using the interfaces of the load cases. First, we create the load cases:
' Get interface for loads.Dim iLoads As RFEM5.iLoadsSet iLoads = iModel.GetLoads
' Create load cases.Dim loadcases(0 To 2) As RFEM5.LoadCase
loadcases(0).Loading.No = 1loadcases(0).SelfWeight = Trueloadcases(0).ToSolve = Trueloadcases(0).SelfWeightFactor.X = 0loadcases(0).SelfWeightFactor.Y = 0loadcases(0).SelfWeightFactor.Z = 1loadcases(0).ActionCategory = Permanent
There are three load cases to be created: self‑weight, snow, and imposed load. In the COM programming, all identifiers are in English. Therefore, Permanent is used for ActionCategory in the case of the self‑weight load case. For the SelfWeightFactor property, you can set the direction and the self‑weight value. However, these apply only if the self‑weight property is set to True. Furthermore, ToSolve must also be set to True in order to include the load case in the calculation and to assign a number to the load case (.Loading.No). The other two load cases are defined more easily, as there is no self‑weight:
loadcases(1).Loading.No = 2loadcases(1).SelfWeight = Falseloadcases(1).ToSolve = Trueloadcases(1).ActionCategory = ShowHLowerThan1000
loadcases(2).Loading.No = 3loadcases(2).SelfWeight = Falseloadcases(2).ToSolve = Trueloadcases(2).ActionCategory = ImposedCategoryA
' Transfer load cases.iLoads.PrepareModificationiLoads.SetLoadCases loadcasesiLoads.FinishModification
The ShowHLowerThan1000 category is used for snow below an altitude of 1,000 m above sea level, and ImposedCategoryA is used for the imposed load of Category A. Then, the load cases can be transferred to RFEM. However, the ILoads interface is used for this instead of the IModelData interface, as the model data is no longer concerned; rather, the load data is.
Create Load and Result Combinations
When creating either load or result combinations, there are only a few differences. The reason for this is that the calculation method and other settings can only be applied after creating the load combination via the corresponding interface. The definition is carried out as in RFEM. For this, you can use the identifier LC (Load Case). The different decimal separators and the uppercase and lowercase letters do not play a role, and both are accepted:
' Create load combinations.Dim loadcombs(0 To 0) As RFEM5.LoadCombination
loadcombs(0).Loading.No = 1loadcombs(0).ToSolve = Trueloadcombs(0).Definition = "1.35*lc1 + 1.5*lc2 + 1.05*lc3"
' Transfer load combinations.iLoads.PrepareModificationiLoads.SetLoadCombinations loadcombsiLoads.FinishModification
' Create result combinations.Dim rescombs(0 To 0) As RFEM5.ResultCombination
rescombs(0).Loading.No = 1rescombs(0).Definition = "1.35*lc1 + 0.75*lc2 + 1.5*lc3"
' Transfer result combinations.iLoads.PrepareModificationiLoads.SetResultCombinations rescombsiLoads.FinishModification
Creating Loads
As mentioned above, the loads will now be transferred using the interfaces for load cases. In our example, no additional loads are created in Load Case 1; in Load Case 2, a trapezoidal distributed load is applied; and Load Case 3 applies a constant linear load and a nodal load. Here is the procedure for Load Case 2:
' Create loads.
' Load Case 2.
Dim iLoadCase As RFEM5.iLoadCaseSet iLoadCase = iLoads.GetLoadCase(2, AtNo)Since we know the load case number, it can be used with AtNo when retrieving the interface:' Create member loads.Dim memLoads() As RFEM5.MemberLoadReDim memLoads(0 To 0)
In this case, the array is not dimensioned at the initialization, but afterwards, because memLoads should be used again for Load Case 3. This has the advantage that the content is reset to the default values when using ReDim again. Under ObjectList, you can select the members for loading, separated by commas or connected with hyphens. In addition to both load values for the load start (Magnitude1) and the load end (Magnitude2), the trapezoidal load requires the specification of distances for the load start (DistanceA) and end (DistanceB). The RelativeDistances property determines whether absolute (False) data in m or relative (True) data of 0‑1 will be used:
memLoads(0).No = 1memLoads(0).ObjectList = "1"memLoads(0).Distribution = TrapezoidalTypememLoads(0).Magnitude1 = 6000#memLoads(0).Magnitude2 = 4000#memLoads(0).RelativeDistances = FalsememLoads(0).DistanceA = 0.2memLoads(0).DistanceB = 0.9
' Transfer member loads.iLoadCase.PrepareModificationiLoadCase.SetMemberLoads memLoadsiLoadCase.FinishModificationWhen transferring the loads, the correct interface must be set; in this case, the ILoadCase interface. The loads of Load Case 3 are defined similarly as follows:' Create nodal loads.Dim nodalLoads(0 To 0) As NodalLoadnodalLoads(0).No = 1nodalLoads(0).nodeList = "2"nodalLoads(0).Component.Force.X = -15000nodalLoads(0).Component.Force.Y = 0nodalLoads(0).Component.Force.Z = 0nodalLoads(0).Component.Moment.X = 0nodalLoads(0).Component.Moment.Y = 0nodalLoads(0).Component.Moment.Z = 0
' Transfer nodal loads.iLoadCase.PrepareModificationiLoadCase.SetNodalLoads nodalLoadsiLoadCase.FinishModification
' Create member loads.ReDim memLoads(0 To 0)memLoads(0).No = 1memLoads(0).ObjectList = "1"memLoads(0).Distribution = UniformTypememLoads(0).Magnitude1 = 5000#
' Transfer member loads.iLoadCase.PrepareModificationiLoadCase.SetMemberLoads memLoadsiLoadCase.FinishModificationWhen closing the program, the error handler routine is completed and the license is unlocked:e: If Err.Number <> 0 Then MsgBox Err.Description, , Err.Source
' COM license is unlocked, program access is possible again.iModel.GetApplication.UnlockLicense
Summary and Overview
The procedures shown in this article are based on the two previous articles. As already mentioned, the structure is similar for all elements. The mentioned exception of nonlinear member releases or nodal supports will be explained in the next article.