diff --git a/src/pyedb/grpc/edb.py b/src/pyedb/grpc/edb.py index 384e5e3691..e2b6423571 100644 --- a/src/pyedb/grpc/edb.py +++ b/src/pyedb/grpc/edb.py @@ -2662,10 +2662,11 @@ def add_project_variable(self, variable_name, variable_value): """ if not variable_name.startswith("$"): variable_name = f"${variable_name}" - if not self.variable_exists(variable_name): - return self.active_db.add_variable(variable_name, variable_value) - else: - self.logger.error(f"Variable {variable_name} already exists.") + if not self.variable_exists(variable_name): + return self.active_db.add_variable(variable_name, variable_value) + else: + self.logger.error(f"Variable {variable_name} already exists.") + return False def add_design_variable(self, variable_name, variable_value, is_parameter=False): """Add a variable to edb. The variable can be a design one or a project variable (using ``$`` prefix). @@ -2708,6 +2709,7 @@ def add_design_variable(self, variable_name, variable_value, is_parameter=False) return self.active_cell.add_variable(variable_name, variable_value) else: self.logger.error(f"Variable {variable_name} already exists.") + return False def change_design_variable_value(self, variable_name, variable_value): """Change a variable value. diff --git a/src/pyedb/grpc/edb_core/modeler.py b/src/pyedb/grpc/edb_core/modeler.py index 7242438bea..2b64d2f2f8 100644 --- a/src/pyedb/grpc/edb_core/modeler.py +++ b/src/pyedb/grpc/edb_core/modeler.py @@ -1107,20 +1107,21 @@ def parametrize_trace_width( layers_name = [layers_name] for net_name in nets_name: for p in self.paths: + _parameter_name = f"{parameter_name}_{p.id}" if not p.net.is_null: if p.net.name == net_name: if not layers_name: if not variable_value: variable_value = p.width self._pedb.active_cell.add_variable( - name=parameter_name, value=variable_value, is_param=True + name=_parameter_name, value=GrpcValue(variable_value), is_param=True ) - p.width = parameter_name + p.width = GrpcValue(_parameter_name, self._pedb.active_cell) elif p.layer.name in layers_name: if not variable_value: variable_value = p.width self._pedb.add_design_variable(parameter_name, variable_value, True) - p.width = GrpcValue(parameter_name) + p.width = GrpcValue(_parameter_name, self._pedb.active_cell) return True def unite_polygons_on_layer(self, layer_name=None, delete_padstack_gemometries=False, net_names_list=[]): diff --git a/tests/grpc/system/test_edb.py b/tests/grpc/system/test_edb.py index af916ba3c4..03a8d35100 100644 --- a/tests/grpc/system/test_edb.py +++ b/tests/grpc/system/test_edb.py @@ -38,7 +38,6 @@ class TestClass: @pytest.fixture(autouse=True) def init(self, local_scratch, target_path, target_path2, target_path4): - # self.edbapp = grpc_edb_app self.local_scratch = local_scratch self.target_path = target_path self.target_path2 = target_path2 @@ -194,22 +193,20 @@ def test_hfss_mesh_operations(self, edb_examples): def test_add_variables(self, edb_examples): """Add design and project variables.""" - # TODO check status of buf #432 assigning parameter on + # Done edbapp = edb_examples.get_si_verse() edbapp.add_design_variable("my_variable", "1mm") assert "my_variable" in edbapp.active_cell.get_all_variable_names() assert edbapp.modeler.parametrize_trace_width("DDR4_DQ25") assert edbapp.modeler.parametrize_trace_width("DDR4_A2") - result, var_server = edbapp.add_design_variable("my_parameter", "2mm", True) - assert result - assert var_server.IsVariableParameter("my_parameter") - result, var_server = edbapp.add_design_variable("my_parameter", "2mm", True) - assert not result - result, var_server = edbapp.add_project_variable("$my_project_variable", "3mm") - assert result - assert var_server - result, var_server = edbapp.add_project_variable("$my_project_variable", "3mm") - assert not result + edbapp.add_design_variable("my_parameter", "2mm", True) + assert "my_parameter" in edbapp.active_cell.get_all_variable_names() + variable_value = edbapp.active_cell.get_variable_value("my_parameter").value + assert variable_value == 2e-3 + assert not edbapp.add_design_variable("my_parameter", "2mm", True) + edbapp.add_project_variable("$my_project_variable", "3mm") + assert edbapp.db.get_variable_value("$my_project_variable") == 3e-3 + assert not edbapp.add_project_variable("$my_project_variable", "3mm") edbapp.close() def test_save_edb_as(self, edb_examples):