diff --git a/_unittest/test_21_Circuit.py b/_unittest/test_21_Circuit.py index 03637fa1480..93c34aa08b4 100644 --- a/_unittest/test_21_Circuit.py +++ b/_unittest/test_21_Circuit.py @@ -448,3 +448,7 @@ def test_35_netlist_data_block(self): def test_36_create_voltage_probe(self): myprobe = self.aedtapp.modeler.components.create_voltage_probe(probe_name="test_probe", location=[0.4, 0.2]) assert type(myprobe.id) is int + + def test_37_draw_graphical_primitives(self): + line = self.aedtapp.modeler.components.create_line([[0, 0], [1, 1]]) + assert line diff --git a/pyaedt/modeler/PrimitivesCircuit.py b/pyaedt/modeler/PrimitivesCircuit.py index 5cae4e83f4d..90d3ebe2d23 100644 --- a/pyaedt/modeler/PrimitivesCircuit.py +++ b/pyaedt/modeler/PrimitivesCircuit.py @@ -1112,6 +1112,32 @@ def arg_with_dim(self, Value, sUnits=None): return val + @pyaedt_function_handler() + def create_line(self, points_array, color=0, line_width=0): + """Draw a graphical line. + + Parameters + ---------- + points_array : list + A nested list of point coordinates. For example, + ``[[x1, y1], [x2, y2], ...]``. + color : string or 3 item list, optional + Color or the line. The default is ``0``. + line_width : float, optional + Width of the line. The default is ``0``. + Returns + ------- + + >>> oEditor.CreateLine + """ + + pointlist = [str(tuple(i)) for i in points_array] + id = self.create_unique_id() + return self.oeditor.CreateLine( + ["NAME:LineData", "Points:=", pointlist, "LineWidth:=", line_width, "Color:=", color, "Id:=", id], + ["NAME:Attributes", "Page:=", 1], + ) + class ComponentInfo(object): """Class that manage Circuit Catalog info."""