Spline

SPLINE curve (DXF Reference), all coordinates have to be 3D coordinates even the spline is only 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.

To create a Spline curve you just need a bunch of fit points - knot values and weights are optional (tested with AutoCAD 2010). If you add additional data, be sure that you know what you do.

See also

Since ezdxf v0.8.9 Spline stores fit- and control points, knots and weights as packed data (array.array).

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()

Spline with reduced count of control points

add_spline_approx()

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 = 1e-10

dxf.fit_tolerance

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

dxf.control_point_tolerance

Control point tolerance (float); default = 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.

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

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

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

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

set_periodic(control_points: Sequence[Vertex], degree=3) → None

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

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

Open rational B-spline with 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[Vertex], weights: Sequence[float], degree: int = 3) → None

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

set_periodic_rational(control_points: Sequence[Vertex], weights: Sequence[float], degree: int = 3) → None

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