set_variable#

VariableManager.set_variable(variable_name, expression=None, readonly=False, hidden=False, description=None, overwrite=True, postprocessing=False, circuit_parameter=True)[source]#

Set the value of a design property or project variable.

Parameters:
variable_namestr

Name of the design property or project variable ($var). If this variable does not exist, a new one is created and a value is set.

expressionstr

Valid string expression within the AEDT design and project structure. For example, "3*cos(34deg)".

readonlybool, optional

Whether to set the design property or project variable to read-only. The default is False.

hiddenbool, optional

Whether to hide the design property or project variable. The default is False.

descriptionstr, optional

Text to display for the design property or project variable in the Properties window. The default is None.

overwritebool, optional

Whether to overwrite an existing value for the design property or project variable. The default is False, in which case this method is ignored.

postprocessingbool, optional
Whether to define a postprocessing variable.

The default is False, in which case the variable is not used in postprocessing.

circuit_parameterbool, optional
Whether to define a parameter in a circuit design or a local parameter.

The default is True, in which case a circuit variable is created as a parameter default.

Returns
——-
bool

True when successful, False when failed.

References

>>> oProject.ChangeProperty
>>> oDesign.ChangeProperty

Examples

Set the value of design property p1 to "10mm", creating the property if it does not already eixst.

>>> aedtapp.variable_manager.set_variable("p1", expression="10mm")

Set the value of design property p1 to "20mm" only if the property does not already exist.

>>> aedtapp.variable_manager.set_variable("p1", expression="20mm", overwrite=False)

Set the value of design property p2 to "10mm", creating the property if it does not already exist. Also make it read-only and hidden and add a description.

>>> aedtapp.variable_manager.set_variable(variable_name="p2", expression="10mm", readonly=True, hidden=True,
...                                       description="This is the description of this variable.")

Set the value of the project variable $p1 to "30mm", creating the variable if it does not exist.

>>> aedtapp.variable_manager.set_variable["$p1"] == "30mm"