diff --git a/src/ansys/aedt/core/modeler/circuits/primitives_nexxim.py b/src/ansys/aedt/core/modeler/circuits/primitives_nexxim.py index d57fbf6e470..4179ed83b9b 100644 --- a/src/ansys/aedt/core/modeler/circuits/primitives_nexxim.py +++ b/src/ansys/aedt/core/modeler/circuits/primitives_nexxim.py @@ -813,7 +813,7 @@ def create_voltage_probe(self, name=None, location=None, angle=0, use_instance_i Parameters ---------- - name : + name : str, optional Name of the voltage probe. The default is ``None``. location : list of float, optional Position on the X axis and Y axis. The default is ``None``. @@ -830,24 +830,87 @@ def create_voltage_probe(self, name=None, location=None, angle=0, use_instance_i References ---------- + >>> oEditor.CreateComponent + + Examples + -------- + >>> from ansys.aedt.core import Circuit + >>> cir = Circuit() + >>> cir.modeler.components.create_voltage_probe(name="probe") + >>> cir.release_desktop(False, False) + """ + return self.__create_probe( + name=name, + probe_type="voltage", + location=location, + angle=angle, + use_instance_id_netlist=use_instance_id_netlist, + ) + + @pyaedt_function_handler() + def create_current_probe(self, name=None, location=None, angle=0, use_instance_id_netlist=False): + """Create a current probe. + + Parameters + ---------- + name : str, optional + Name of the current probe. The default is ``None``. + location : list of float, optional + Position on the X axis and Y axis. The default is ``None``. + angle : float, optional + Angle rotation in degrees. The default is ``0``. + use_instance_id_netlist : bool, optional + Whether to use the instance ID in the net list. + The default is ``False``. + + Returns + ------- + :class:`ansys.aedt.core.modeler.cad.object_3dcircuit.CircuitComponent` + Circuit Component Object. + References + ---------- >>> oEditor.CreateComponent + + Examples + -------- + >>> from ansys.aedt.core import Circuit + >>> cir = Circuit() + >>> cir.modeler.components.create_current_probe(name="probe") + >>> cir.release_desktop(False, False) """ + return self.__create_probe( + name=name, + probe_type="current", + location=location, + angle=angle, + use_instance_id_netlist=use_instance_id_netlist, + ) + + def __create_probe(self, name=None, probe_type="voltage", location=None, angle=0.0, use_instance_id_netlist=False): + if probe_type == "voltage": + component_name = "VPROBE" + elif probe_type == "current": + component_name = "IPROBE" + else: # pragma: no cover + self.logger.error("Wrong probe type assigned.") + return False + if location is None: location = [] else: location = [location[0] + 0.2 * 24.4 / 1000, location[1] + 0.2 * 24.4 / 1000] cmpid = self.create_component( - None, + name, component_library="Probes", - component_name="VPROBE", + component_name=component_name, location=location, angle=angle, use_instance_id_netlist=use_instance_id_netlist, ) - - cmpid.set_property("Name", name) + if name: + cmpid.set_property("InstanceName", name) return cmpid @pyaedt_function_handler(compname="name") diff --git a/tests/system/general/test_21_Circuit.py b/tests/system/general/test_21_Circuit.py index 5144c237bb4..6d99dd229ae 100644 --- a/tests/system/general/test_21_Circuit.py +++ b/tests/system/general/test_21_Circuit.py @@ -517,7 +517,7 @@ def test_35_netlist_data_block(self): assert self.aedtapp.analyze() def test_36_create_voltage_probe(self): - myprobe = self.aedtapp.modeler.components.create_voltage_probe(name="test_probe", location=[0.4, 0.2]) + myprobe = self.aedtapp.modeler.components.create_voltage_probe(name="voltage_probe") assert type(myprobe.id) is int def test_37_draw_graphical_primitives(self): @@ -988,3 +988,10 @@ def test_51_import_asc(self): self.aedtapp.insert_design("ASC") asc_file = os.path.join(TESTS_GENERAL_PATH, "example_models", test_subfolder, "butter.asc") assert self.aedtapp.create_schematic_from_asc_file(asc_file) + + def test_52_create_current_probe(self): + iprobe = self.aedtapp.modeler.schematic.create_current_probe(name="test_probe", location=[0.4, 0.2]) + assert type(iprobe.id) is int + assert iprobe.InstanceName == "test_probe" + iprobe2 = self.aedtapp.modeler.schematic.create_current_probe(location=[0.8, 0.2]) + assert type(iprobe2.id) is int