The parameters of a model can be modified using the IModel interface (as of IModel3):
Sub test_parameter()
Dim iApp As RFEM5.Application
Set iApp = GetObject(, "RFEM5.Application")
iApp.LockLicense
Dim j As Integer
j = iApp.GetModelCount
Dim iMod As RFEM5.IModel3
Set iMod = iApp.GetActiveModel
On Error GoTo e
Dim formParams() As RFEM5.FormulaParameter
' get all formula parameters
formParams = iMod.GetFormulaParameters
' delete all formula parameters
iMod.CleanFormulaParameters
' set list of formula parameters
ReDim 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 = LengthUnitType
formParams(UBound(formParams, 1)).Value = 0
formParams(UBound(formParams, 1)).ValueType = DoubleType
formParams(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.Source
iMod.GetApplication.UnlockLicense
Set 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.