The parameters of a model can be modified using the IModel interface (as of IModel3):
Sub test_parameter()
Dim iApp As RFEM5.ApplicationSet iApp = GetObject(, "RFEM5.Application")
iApp.LockLicense
Dim j As Integerj = iApp.GetModelCount
Dim iMod As RFEM5.IModel3Set iMod = iApp.GetActiveModel
On Error GoTo e
Dim formParams() As RFEM5.FormulaParameter
' get all formula parametersformParams = iMod.GetFormulaParameters
' delete all formula parametersiMod.CleanFormulaParameters
' set list of formula parametersReDim Preserve formParams(0 To UBound(formParams, 1) + 1)formParams(UBound(formParams, 1)).Name = "p"formParams(UBound(formParams, 1)).Unit = "m"formParams(UBound(formParams, 1)).UnitType = LengthUnitTypeformParams(UBound(formParams, 1)).Value = 0formParams(UBound(formParams, 1)).ValueType = DoubleTypeformParams(UBound(formParams, 1)).Comment = "new parameter"formParams(UBound(formParams, 1)).Formula = "b/3"formParams(UBound(formParams, 1)).RangeOfValues = "(3;5.5>"
iMod.SetFormulaParameters formParams
e:
If Err.Number <> 0 Then MsgBox Err.description, vbCritical, Err.SourceiMod.GetApplication.UnlockLicenseSet iMod = Nothing
End Sub
It is only possible to read out all the parameters using the GetFormulaParameters() function. The modified or new parameters can then be transferred again as a list with the SetFormulaParameters() function. Thus, no individual parameters can be read out or written.
It should be noted that the "Value" related to its type (ValueTyp) and its unit (Unit) must be within the defined limits (RangeOfValues); otherwise, an error message appears. If the value is calculated, as in the example, it is irrelevant and the value calculated with the formula (Formula) must be within the limits, if limits are defined.