Spline

The SPLINE entity (DXF Reference) is a 3D curve, all coordinates have to be 3D coordinates even if the spline is just a 2D planar curve.

The spline curve is defined by control points, knot values and weights. The control points establish the spline, the various types of knot vector determines the shape of the curve and the weights of rational splines define how strong a control point influences the shape.

A SPLINE can be created just from fit points - knot values and weights are optional (tested with AutoCAD 2010). If you add additional data, be sure you know what you do, because invalid data may invalidate the whole DXF file.

The function ezdxf.math.fit_points_to_cad_cv() calculates control vertices from given fit points. This control vertices define a cubic B-spline which matches visually the SPLINE entities created by BricsCAD and AutoCAD from fit points.

See also

Subclass of

ezdxf.entities.DXFGraphic

DXF type

'SPLINE'

Factory function

see table below

Inherited DXF attributes

Common graphical DXF attributes

Required DXF version

DXF R2000 ('AC1015')

Factory Functions

Basic spline entity

add_spline()

Spline control frame from fit points

add_spline_control_frame()

Open uniform spline

add_open_spline()

Closed uniform spline

add_closed_spline()

Open rational uniform spline

add_rational_spline()

Closed rational uniform spline

add_closed_rational_spline()

class ezdxf.entities.Spline

All points in WCS as (x, y, z) tuples

dxf.degree

Degree of the spline curve (int).

dxf.flags

Bit coded option flags, constants defined in ezdxf.lldxf.const:

dxf.flags

Value

Description

CLOSED_SPLINE

1

Spline is closed

PERIODIC_SPLINE

2

RATIONAL_SPLINE

4

PLANAR_SPLINE

8

LINEAR_SPLINE

16

planar bit is also set

dxf.n_knots

Count of knot values (int), automatically set by ezdxf (read only)

dxf.n_fit_points

Count of fit points (int), automatically set by ezdxf (read only)

dxf.n_control_points

Count of control points (int), automatically set by ezdxf (read only)

dxf.knot_tolerance

Knot tolerance (float); default is 1e-10

dxf.fit_tolerance

Fit tolerance (float); default is 1e-10

dxf.control_point_tolerance

Control point tolerance (float); default is 1e-10

dxf.start_tangent

Start tangent vector as 3D vector in WCS

dxf.end_tangent

End tangent vector as 3D vector in WCS

closed

True if spline is closed. A closed spline has a connection from the last control point to the first control point. (read/write)

control_points

VertexArray of control points in WCS.

fit_points

VertexArray of fit points in WCS.

knots

Knot values as array.array('d').

weights

Control point weights as array.array('d').

control_point_count() int

Count of control points.

fit_point_count() int

Count of fit points.

knot_count() int

Count of knot values.

construction_tool() BSpline

Returns the construction tool ezdxf.math.BSpline.

apply_construction_tool(s) Spline

Apply SPLINE data from a BSpline construction tool or from a geomdl.BSpline.Curve object.

flattening(distance: float, segments: int = 4) Iterator[Vec3]

Adaptive recursive flattening. The argument segments is the minimum count of approximation segments between two knots, if the distance from the center of the approximation segment to the curve is bigger than distance the segment will be subdivided.

Parameters:
  • distance – maximum distance from the projected curve point onto the segment chord.

  • segments – minimum segment count between two knots

set_open_uniform(control_points: Sequence[UVec], degree: int = 3) None

Open B-spline with a uniform knot vector, start and end at your first and last control points.

set_uniform(control_points: Sequence[UVec], degree: int = 3) None

B-spline with a uniform knot vector, does NOT start and end at your first and last control points.

set_closed(control_points: Sequence[UVec], degree=3) None

Closed B-spline with a uniform knot vector, start and end at your first control point.

set_open_rational(control_points: Sequence[UVec], weights: Sequence[float], degree: int = 3) None

Open rational B-spline with a uniform knot vector, start and end at your first and last control points, and has additional control possibilities by weighting each control point.

set_uniform_rational(control_points: Sequence[UVec], weights: Sequence[float], degree: int = 3) None

Rational B-spline with a uniform knot vector, does NOT start and end at your first and last control points, and has additional control possibilities by weighting each control point.

set_closed_rational(control_points: Sequence[UVec], weights: Sequence[float], degree: int = 3) None

Closed rational B-spline with a uniform knot vector, start and end at your first control point, and has additional control possibilities by weighting each control point.

transform(m: Matrix44) Spline

Transform the SPLINE entity by transformation matrix m inplace.

classmethod from_arc(entity: DXFGraphic) Spline

Create a new SPLINE entity from a CIRCLE, ARC or ELLIPSE entity.

The new SPLINE entity has no owner, no handle, is not stored in the entity database nor assigned to any layout!