diff --git a/_unittest/test_28_Maxwell3D.py b/_unittest/test_28_Maxwell3D.py index 9cb02156b5e..fb1a7b4ede0 100644 --- a/_unittest/test_28_Maxwell3D.py +++ b/_unittest/test_28_Maxwell3D.py @@ -483,12 +483,16 @@ def test_32_matrix(self, add_app): rectangle2 = m3d.modeler.create_rectangle(0, [9, 1.5, 0], [2.5, 5], name="Sheet2") rectangle3 = m3d.modeler.create_rectangle(0, [16.5, 1.5, 0], [2.5, 5], name="Sheet3") rectangle4 = m3d.modeler.create_rectangle(0, [32.5, 1.5, 0], [2.5, 5], name="Sheet4") + box1 = m3d.modeler.create_box([0, 0, 0], [10, 10, 5], "MyBox1") + box2 = m3d.modeler.create_box([10, 10, 10], [10, 10, 5], "MyBox2") m3d.assign_voltage(rectangle1.faces[0], amplitude=1, name="Voltage1") m3d.assign_voltage("Sheet1", amplitude=1, name="Voltage5") m3d.assign_voltage(rectangle2.faces[0], amplitude=1, name="Voltage2") m3d.assign_voltage(rectangle3.faces[0], amplitude=1, name="Voltage3") m3d.assign_voltage(rectangle4.faces[0], amplitude=1, name="Voltage4") + m3d.assign_voltage(box1.faces, amplitude=1, name="Voltage6") + m3d.assign_voltage(box2, amplitude=1, name="Voltage7") L = m3d.assign_matrix(assignment="Voltage1") assert L.props["MatrixEntry"]["MatrixEntry"][0]["Source"] == "Voltage1" diff --git a/pyaedt/maxwell.py b/pyaedt/maxwell.py index 99a61115fe3..bb1b321f486 100644 --- a/pyaedt/maxwell.py +++ b/pyaedt/maxwell.py @@ -1007,7 +1007,13 @@ def assign_voltage(self, assignment, amplitude=1, name=None): else: props = OrderedDict({"Faces": assignment, "Value": amplitude}) else: - props = OrderedDict({"Faces": assignment, "Voltage": amplitude}) + object_names_set = set(self.modeler.object_names) + props = OrderedDict({"Faces": [], "Objects": [], "Voltage": amplitude}) + for element in assignment: + if isinstance(element, str) and element in object_names_set: + props["Objects"].append(element) + else: + props["Faces"].append(element) bound = BoundaryObject(self, name, props, "Voltage") if bound.create(): self._boundaries[bound.name] = bound