set_variable#
- VariableManager.set_variable(name, expression=None, read_only=False, hidden=False, description=None, sweep=True, overwrite=True, is_post_processing=False, circuit_parameter=True)#
Set the value of a design property or project variable.
- Parameters:
- name
str
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.- expression
str
Valid string expression within the AEDT design and project structure. For example,
"3*cos(34deg)"
.- read_onlybool,
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
.- description
str
,optional
Text to display for the design property or project variable in the
Properties
window. The default isNone
.- sweepbool,
optional
Allows you to designate variables to include in solution indexing as a way to permit faster post-processing. Variables with the Sweep check box cleared are not used in solution indexing. The default is
True
.- 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.- is_post_processingbool,
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.
- name
References
>>> oProject.ChangeProperty >>> oDesign.ChangeProperty
Examples
>>> from ansys.aedt.core import Maxwell3d >>> aedtapp = Maxwell3d(specified_version="2024.2")
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(name="p2", ... expression="10mm", ... read_only=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"