create_polyline#

Modeler3D.create_polyline(points, segment_type=None, cover_surface=False, close_surface=False, name=None, material=None, xsection_type=None, xsection_orient=None, xsection_width=1, xsection_topwidth=1, xsection_height=1, xsection_num_seg=0, xsection_bend_type=None, non_model=False)[source]#

Draw a polyline object in the 3D modeler.

This method retrieves the pyaedt.modeler.Primitives.Polyline object, which has additional methods for manipulating the polyline. For example, you can use pyaedt.modeler.Primitives.Polyline.insert_segment() to insert a segment or pyaedt.modeler.Primitives.Polyline.id to retrieve the ID of the polyline object.

Parameters:
pointslist

Array of positions of each point of the polyline. A position is a list of 2D or 3D coordinates. Position coordinate values can be numbers or valid AEDT string expressions. For example, [0, 1, 2], ["0mm", "5mm", "1mm"], or ["x1", "y1", "z1"].

segment_typestr or PolylineSegment or list, optional

The default behavior is to connect all points as "Line" segments. The default is None. Use a "PolylineSegment", for "Line", "Arc", "Spline", or "AngularArc". A list of segment types (str or pyaedt.modeler.Primitives.PolylineSegment) is valid for a compound polyline.

cover_surfacebool, optional

The default is False.

close_surfacebool, optional

The default is False, which automatically joins the starting and ending points.

namestr, optional

Name of the polyline. The default is None.

materialstr, optional

Name of the material. The default is None, in which case the default material is assigned.

xsection_typestr, optional

Type of the cross-section. Options are "Line", "Circle", "Rectangle", and "Isosceles Trapezoid". The default is None.

xsection_orientstr, optional

Direction of the normal vector to the width of the cross-section. Options are "X", "Y", "Z", and "Auto". The default is None, which sets the direction to "Auto".

xsection_widthfloat or str, optional

Width or diameter of the cross-section for all types. The default is 1.

xsection_topwidthfloat or str, optional

Top width of the cross-section for type "Isosceles Trapezoid" only. The default is 1.

xsection_heightfloat or str

Height of the cross-section for type "Rectangle" or "Isosceles Trapezoid" only. The default is 1.

xsection_num_segint, optional

Number of segments in the cross-section surface for type "Circle", "Rectangle", or "Isosceles Trapezoid". The default is 0. The value must be 0 or greater than 2.

xsection_bend_typestr, optional

Type of the bend for the cross-section. The default is None, in which case the bend type is set to "Corner". For the type "Circle", the bend type should be set to "Curved".

non_modelbool, optional

Either if the polyline will be created as model or unmodel object.

Returns:
pyaedt.modeler.polylines.Polyline

Polyline object.

References

>>> oEditor.CreatePolyline

Examples

Set up the desktop environment.

>>> from pyaedt.modeler.cad.polylines import PolylineSegment
>>> from pyaedt import Desktop
>>> from pyaedt import Maxwell3d
>>> desktop=Desktop(specified_version="2021.2", new_desktop_session=False)
>>> aedtapp = Maxwell3d()
>>> aedtapp.modeler.model_units = "mm"
>>> modeler = aedtapp.modeler

Define some test data points.

>>> test_points = [["0mm", "0mm", "0mm"], ["100mm", "20mm", "0mm"],
...                ["71mm", "71mm", "0mm"], ["0mm", "100mm", "0mm"]]

The default behavior assumes that all points are to be connected by line segments. Optionally specify the name.

>>> P1 = modeler.create_polyline(test_points,name="PL_line_segments")

Specify that the first segment is a line and the last three points define a three-point arc.

>>> P2 = modeler.create_polyline(test_points,segment_type=["Line", "Arc"],name="PL_line_plus_arc")

Redraw the 3-point arc alone from the last three points and additionally specify five segments using PolylineSegment.

>>> P3 = modeler.create_polyline(test_points[1:],segment_type=PolylineSegment(segment_type="Arc", num_seg=7),
...                              name="PL_segmented_arc")

Specify that the four points form a spline and add a circular cross-section with a diameter of 1 mm.

>>> P4 = modeler.create_polyline(test_points,segment_type="Spline",name="PL_spline",
...                              xsection_type="Circle",xsection_width="1mm")

Use the PolylineSegment object to specify more detail about the individual segments. Create a center point arc starting from the position test_points[1], rotating about the center point position test_points[0] in the XY plane.

>>> start_point = test_points[1]
>>> center_point = test_points[0]
>>> segment_def = PolylineSegment(segment_type="AngularArc", arc_center=center_point,
...                                arc_angle="90deg", arc_plane="XY")
>>> modeler.create_polyline(start_point,segment_type=segment_def,name="PL_center_point_arc")

Create a spline using a list of variables for the coordinates of the points.

>>> x0, y0, z0 = "0", "0", "1"
>>> x1, y1, z1 = "1", "3", "1"
>>> x2, y2, z2 = "2", "2", "1"
>>> P5 = modeler.create_polyline(points=[[x0, y0, z0], [x1, y1, z1], [x2, y2, z2]],
...                              segment_type="Spline",name="polyline_with_variables")