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
ansys.aedt.core.modeler.cad.primitives.Polyline
object, which has additional methods for manipulating the polyline. For example, you can useansys.aedt.core.modeler.cad.primitives.Polyline.insert_segment()
to insert a segment oransys.aedt.core.modeler.cad.primitives.Polyline.id
to retrieve the ID of the polyline object.- Parameters:
- points
list
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_type
str
orPolylineSegment
orlist
,optional
The default behavior is to connect all points as
"Line"
segments. The default isNone
. Use a"PolylineSegment"
, for"Line"
,"Arc"
,"Spline"
, or"AngularArc"
. A list of segment types (str oransys.aedt.core.modeler.cad.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.- name
str
,optional
Name of the polyline. The default is
None
.- material
str
,optional
Name of the material. The default is
None
, in which case the default material is assigned.- xsection_type
str
,optional
Type of the cross-section. Options are
"Line"
,"Circle"
,"Rectangle"
, and"Isosceles Trapezoid"
. The default isNone
.- xsection_orient
str
,optional
Direction of the normal vector to the width of the cross-section. Options are
"X"
,"Y"
,"Z"
, and"Auto"
. The default isNone
, which sets the direction to"Auto"
.- xsection_width
float
orstr
,optional
Width or diameter of the cross-section for all types. The default is
1
.- xsection_topwidth
float
orstr
,optional
Top width of the cross-section for type
"Isosceles Trapezoid"
only. The default is1
.- xsection_height
float
orstr
Height of the cross-section for type
"Rectangle"
or"Isosceles Trapezoid"
only. The default is1
.- xsection_num_seg
int
,optional
Number of segments in the cross-section surface for type
"Circle"
,"Rectangle"
, or"Isosceles Trapezoid"
. The default is0
. The value must be0
or greater than2
.- xsection_bend_type
str
,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.
- points
- Returns:
ansys.aedt.core.modeler.polylines.Polyline
Polyline object.
References
>>> oEditor.CreatePolyline
Examples
Set up the desktop environment.
>>> from ansys.aedt.core.modeler.cad.polylines import PolylineSegment >>> from ansys.aedt.core import Desktop >>> from ansys.aedt.core import Maxwell3d >>> desktop=Desktop(version="2021.2", new_desktop=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 positiontest_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")