Click or drag to resize

IVariablesAdd Method

Adds new variable to the project. Once the variable is added, Expression is evaluated to calculate variable DoubleValue. If equation is specified as the Expression, variables used in the equation must be already present in the project. Mathematical function, e.g. sin(), exp() etc., can also be used in Expression.

Namespace:  EMInvent.InventSim.COMServer
Assembly:  InventSim (in InventSim.exe) Version: 5.1.12.6+develop
Syntax
IVariable Add(
	string name,
	string expression,
	bool isOptimizable,
	double min,
	double max
)

Parameters

name
Type: SystemString
Variable name.
expression
Type: SystemString
Expression to be evaluated.
isOptimizable
Type: SystemBoolean
Flag indicating the the variable should be used in optimization.
min
Type: SystemDouble
Minimum value of optimizable variable.
max
Type: SystemDouble
Maximum value of optimizable variable.

Return Value

Type: IVariable
Reference to newly created variable.
Examples
To add two variables "a" and "b", where second is sinus function of the first:
IVariable a = app.ActiveProject.Variables.Add("a", "4.34", false, 0, 0);
IVariable b = app.ActiveProject.Variables.Add("b", "sin(a)", false, 0, 0);
See Also