VariableManager#

class pyedb.dotnet.database.Variables.VariableManager(app)#

Bases: object

Manages design properties and project variables.

Design properties are the local variables in a design. Project variables are defined at the project level and start with $.

This class provides access to all variables or a subset of the variables. Manipulation of the numerical or string definitions of variable values is provided in the pyedb.dotnet.database.Variables.Variable class.

Parameters:
variablesdict

Dictionary of all design properties and project variables in the active design.

design_variablesdict

Dictionary of all design properties in the active design.

project_variablesdict

Dictionary of all project variables available to the active design (key by variable name).

dependent_variablesdict

Dictionary of all dependent variables available to the active design (key by variable name).

independent_variablesdict

Dictionary of all independent variables (constant numeric values) available to the active design (key by variable name).

independent_design_variablesdict
independent_project_variablesdict
variable_namesstr or list

One or more variable names.

project_variable_namesstr or list

One or more project variable names.

design_variable_namesstr or list

One or more design variable names.

dependent_variable_namesstr or list

All dependent variable names within the project.

independent_variable_nameslist of str

All independent variable names within the project. These can be sweep variables for optimetrics.

independent_project_variable_namesstr or list

All independent project variable names within the project. These can be sweep variables for optimetrics.

independent_design_variable_namesstr or list

All independent design properties (local variables) within the project. These can be sweep variables for optimetrics.

Examples

>>> from ansys.aedt.core.maxwell import Maxwell3d
>>> from ansys.aedt.core.desktop import Desktop
>>> d = Desktop()
>>> aedtapp = Maxwell3d()

Define some test variables.

>>> aedtapp["Var1"] = 3
>>> aedtapp["Var2"] = "12deg"
>>> aedtapp["Var3"] = "Var1 * Var2"
>>> aedtapp["$PrjVar1"] = "pi"

Get the variable manager for the active design.

>>> v = aedtapp.variable_manager

Get a dictionary of all project and design variables.

>>> v.variables
{'Var1': ,
 'Var2': ,
 'Var3': ,
 '$PrjVar1': }

Get a dictionary of only the design variables.

>>> v.design_variables
{'Var1': ,
 'Var2': ,
 'Var3': }

Get a dictionary of only the independent design variables.

>>> v.independent_design_variables
{'Var1': ,
 'Var2': }

Overview#

decompose

Decompose a variable string to a floating with its unit.

get_expression

Retrieve the variable value of a project or design variable as a string.

aedt_object

Retrieve an AEDT object.

set_variable

Set the value of a design property or project variable.

delete_separator

Delete a separator from either the active project or design.

delete_variable

Delete a variable.

variables

Variables.

design_variables

Design variables.

project_variables

Project variables.

post_processing_variables

Post Processing variables.

independent_variables

Independent variables.

independent_project_variables

Independent project variables.

independent_design_variables

Independent design variables.

dependent_variables

Dependent variables.

dependent_project_variables

Dependent project variables.

dependent_design_variables

Dependent design variables.

variable_names

List of variables.

project_variable_names

List of project variables.

design_variable_names

List of design variables.

independent_project_variable_names

List of independent project variables.

independent_design_variable_names

List of independent design variables.

independent_variable_names

List of independent variables.

dependent_project_variable_names

List of dependent project variables.

dependent_design_variable_names

List of dependent design variables.

dependent_variable_names

List of dependent variables.

__delitem__

Implement del with array name or index.

__getitem__

__setitem__

Import detail#

from pyedb.dotnet.database.Variables import VariableManager

Property detail#

property VariableManager.variables#

Variables.

Returns:
dict

Dictionary of the Variable objects for each project variable and each design property in the active design.

References

>>> oProject.GetVariables
>>> oDesign.GetVariables
>>> oProject.GetChildObject("Variables").GetChildNames
>>> oDesign.GetChildObject("Variables").GetChildNames
property VariableManager.design_variables#

Design variables.

Returns:
dict

Dictionary of the design properties (local properties) in the design.

References

>>> oDesign.GetVariables
>>> oDesign.GetChildObject("Variables").GetChildNames
property VariableManager.project_variables#

Project variables.

Returns:
dict

Dictionary of the project properties.

References

>>> oProject.GetVariables
>>> oProject.GetChildObject("Variables").GetChildNames
property VariableManager.post_processing_variables#

Post Processing variables.

Returns:
dict

Dictionary of the post processing variables (constant numeric values) available to the design.

References

>>> oProject.GetVariables
>>> oDesign.GetVariables
>>> oProject.GetChildObject("Variables").GetChildNames
>>> oDesign.GetChildObject("Variables").GetChildNames
property VariableManager.independent_variables#

Independent variables.

Returns:
dict

Dictionary of the independent variables (constant numeric values) available to the design.

References

>>> oProject.GetVariables
>>> oDesign.GetVariables
>>> oProject.GetChildObject("Variables").GetChildNames
>>> oDesign.GetChildObject("Variables").GetChildNames
property VariableManager.independent_project_variables#

Independent project variables.

Returns:
dict

Dictionary of the independent project variables available to the design.

References

>>> oProject.GetVariables
>>> oProject.GetChildObject("Variables").GetChildNames
property VariableManager.independent_design_variables#

Independent design variables.

Returns:
dict

Dictionary of the independent design properties (local variables) available to the design.

References

>>> oDesign.GetVariables
>>> oDesign.GetChildObject("Variables").GetChildNames
property VariableManager.dependent_variables#

Dependent variables.

Returns:
dict

Dictionary of the dependent design properties (local variables) and project variables available to the design.

References

>>> oProject.GetVariables
>>> oDesign.GetVariables
>>> oProject.GetChildObject("Variables").GetChildNames
>>> oDesign.GetChildObject("Variables").GetChildNames
property VariableManager.dependent_project_variables#

Dependent project variables.

Returns:
dict

Dictionary of the dependent project variables available to the design.

References

>>> oProject.GetVariables
>>> oProject.GetChildObject("Variables").GetChildNames
property VariableManager.dependent_design_variables#

Dependent design variables.

Returns:
dict

Dictionary of the dependent design properties (local variables) available to the design.

References

>>> oDesign.GetVariables
>>> oDesign.GetChildObject("Variables").GetChildNames
property VariableManager.variable_names#

List of variables.

property VariableManager.project_variable_names#

List of project variables.

References

>>> oProject.GetVariables
>>> oProject.GetChildObject("Variables").GetChildNames
property VariableManager.design_variable_names#

List of design variables.

References

>>> oDesign.GetVariables
>>> oDesign.GetChildObject("Variables").GetChildNames
property VariableManager.independent_project_variable_names#

List of independent project variables.

References

>>> oProject.GetVariables
>>> oProject.GetChildObject("Variables").GetChildNames
property VariableManager.independent_design_variable_names#

List of independent design variables.

References

>>> oDesign.GetVariables
>>> oDesign.GetChildObject("Variables").GetChildNames
property VariableManager.independent_variable_names#

List of independent variables.

References

>>> oProject.GetVariables
>>> oDesign.GetVariables
>>> oProject.GetChildObject("Variables").GetChildNames
>>> oDesign.GetChildObject("Variables").GetChildNames
property VariableManager.dependent_project_variable_names#

List of dependent project variables.

References

>>> oProject.GetVariables
>>> oProject.GetChildObject("Variables").GetChildNames
property VariableManager.dependent_design_variable_names#

List of dependent design variables.

References

>>> oDesign.GetVariables
>>> oDesign.GetChildObject("Variables").GetChildNames
property VariableManager.dependent_variable_names#

List of dependent variables.

References

>>> oProject.GetVariables
>>> oDesign.GetVariables
>>> oProject.GetChildObject("Variables").GetChildNames
>>> oDesign.GetChildObject("Variables").GetChildNames

Method detail#

VariableManager.decompose(variable_value)#

Decompose a variable string to a floating with its unit.

Parameters:
variable_valuestr
Returns:
tuple

The float value of the variable and the units exposed as a string.

Examples

>>> hfss = Hfss()
>>> print(hfss.variable_manager.decompose("5mm"))
>>> (5.0, "mm")
>>> hfss["v1"] = "3N"
>>> print(hfss.variable_manager.decompose("v1"))
>>> (3.0, "N")
>>> hfss["v2"] = "2*v1"
>>> print(hfss.variable_manager.decompose("v2"))
>>> (6.0, "N")
VariableManager.__delitem__(key)#

Implement del with array name or index.

VariableManager.__getitem__(variable_name)#
VariableManager.__setitem__(variable, value)#
VariableManager.get_expression(variable_name)#

Retrieve the variable value of a project or design variable as a string.

References

>>> oProject.GetVariableValue
>>> oDesign.GetVariableValue
VariableManager.aedt_object(variable)#

Retrieve an AEDT object.

Parameters:
variablestr
Name of the variable.
VariableManager.set_variable(variable_name, expression=None, readonly=False, hidden=False, description=None, overwrite=True, postprocessing=False, circuit_parameter=True)#

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"
VariableManager.delete_separator(separator_name)#

Delete a separator from either the active project or design.

Parameters:
separator_namestr

Value to use for the delimiter.

Returns:
bool

True when the separator exists and can be deleted, False otherwise.

References

>>> oProject.ChangeProperty
>>> oDesign.ChangeProperty
VariableManager.delete_variable(var_name)#

Delete a variable.

Parameters:
var_namestr

Name of the variable.

Returns:
bool

True when successful, False when failed.

References

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