Spline¶
Render Bspline as 2D/3D Polyline
, can be used with DXF R12. The advantage over R12Spline
is the real
3D support which means the Bspline curve vertices has not to be in a plane and no hassle with UCS for 3D
placing.

class
ezdxf.addons.
Spline
¶

Spline.
__init__
(points=None, segments=100)¶ Parameters:  points – spline definition points
 segments – count of line segments for approximation, vertex count is segments+1

Spline.
render_as_fit_points
(layout, degree=3, method='distance', power=.5, dxfattribs=None)¶ Render a Bspline as 2d/3d polyline, where the definition points are fit points.
 2d points in > add_polyline2d()
 3d points in > add_polyline3d()
To get vertices at fit points, use method=’uniform’ and use Spline.subdivide(count), where count is the subsegment count, count=4, means 4 line segments between two definition points.
Parameters:

Spline.
render_open_bspline
(layout, degree=3, dxfattribs=None)¶ Render an open uniform BSpline as 3D
Polyline
. Definition points are control points.Parameters:

Spline.render_uniform_bspline(layout, degree=3, dxfattribs=None):
Render a uniform BSpline as 3D
Polyline
. Definition points are control points.Parameters:

Spline.
render_closed_bspline
(layout, degree=3, dxfattribs=None)¶ Render a closed uniform BSpline as 3D
Polyline
. Definition points are control points.Parameters:

Spline.
render_open_rbspline
(layout, weights, degree=3, dxfattribs=None)¶ Render a rational open uniform BSpline as 3D
Polyline
. Definition points are control points.Parameters:

Spline.
render_uniform_rbspline
(layout, weights, degree=3, dxfattribs=None)¶ Render a rational uniform BSpline as 3D
Polyline
. Definition points are control points.Parameters:
R12Spline¶
DXF R12 supports 2D Bsplines, but Autodesk do not document the usage in the DXF Reference. The base entity for splines in DXF R12 is the POLYLINE entity. The spline itself is always in a plane, but as any 2D entity, the spline can be transformed into the 3D object by elevation and extrusion (OCS, UCS).
The result is not better than Spline
, it is also just a POLYLINE, but as with all tools, I never know if
someone needs it some day.
class:  R12Spline 


R12Spline.
__init__
(control_points, degree=2, closed=True)¶ Parameters:  control_points – Bspline control frame vertices as (x, y) tuples
 degree – degree of Bspline, 2 or 3 is valid
 closed – True for closed curve

R12Spline.
render
(layout, segments=40, ucs=None, dxfattribs=None)¶ Renders the Bspline into layout as 2D
Polyline
entity. Use anUCS
to place the 2D spline in 3D space, seeR12Spline.approximate()
for more information.Parameters: Returns: the
Polyline
object

R12Spline.
approximate
(segments=40, ucs=None)¶ Parameters:  segments – count of line segments to use, vertex count is segments+1
 ucs –
UCS
definition, control points in ucs coordinates.
Returns: Approximate Bspline by a polyline with segments line segments. If ucs is not None, ucs defines an
UCS
, to transformed the curve into OCS. The control points are placed in this UCS xyplane, you shouldn’t use zaxis coordinates, if so make sure all control points are a plane parallel to the OCS base plane (UCS xyplane), else the result is unpredictable and depends on the used CAD application (may be crash).
Bezier¶
Render bezier curve as 3D Polyline
.
The Bezier
class is implemented with multiple segments, each segment is an optimized 4 point bezier curve, the
4 control points of the curve are: the start point (1) and the end point (4), point (2) is start point + start vector
and point (3) is end point + end vector. Each segment has its own approximation count.

class
ezdxf.addons.
Bezier
¶

Bezier.
start
(point, tangent)¶ Set start point and start tangent.
Parameters:  point – start point as (x, y, z) tuple
 tangent – start tangent as vector, also (x, y, z) tuple

Bezier.append(point, tangent1, tangent2=None, segments=20):
Append a control point with two control tangents.
Parameters:  point – the control point as (x, y, z) tuple
 tangent1 – first control tangent as vector left of point
 tangent2 – second control tangent as vector right of point, if omitted tangent2 = tangent1
 segments – count of line segments for polyline approximation, count of line segments from previous control point to this point.
EulerSpiral¶
Render euler spiral as 3D Polyline
or Spline
.

class
ezdxf.addons.
EulerSpiral
¶

EulerSpiral.
__init__
(curvature=1)¶ Parameters: curvature – Radius of curvature

EulerSpiral.
render_polyline
(layout, length=1, segments=100, matrix=None, dxfattribs=None)¶ Render euler spiral as 3D
Polyline
entity into layout.Parameters: