Forms¶
This module provides functions to create 2D and 3D forms as vertices or mesh objects.
2D Forms
3D Forms
3D Form Builder
2D Forms¶
Basic 2D shapes as iterable of
Vector
.

ezdxf.render.forms.
circle
(count: int, radius: float = 1, elevation: float = 0, close: bool = False) → Iterable[Vector]¶ Create polygon vertices for a circle with radius and count corners, elevation is the zaxis for all vertices.
 Parameters
count – count of polygon vertices
radius – circle radius
elevation – zaxis for all vertices
close – yields first vertex also as last vertex if
True
.
 Returns
vertices in counter clockwise orientation as
Vector
objects

ezdxf.render.forms.
square
(size: float = 1.) → Tuple[Vector, Vector, Vector, Vector]¶ Returns 4 vertices for a square with a side length of size, lower left corner is
(0, 0)
, upper right corner is (size, size).

ezdxf.render.forms.
box
(sx: float = 1., sy: float = 1.) → Tuple[Vector, Vector, Vector, Vector]¶ Returns 4 vertices for a box sx by sy, lower left corner is
(0, 0)
, upper right corner is (sx, sy).

ezdxf.render.forms.
ellipse
(count: int, rx: float = 1, ry: float = 1, start_param: float = 0, end_param: float = 2 * pi, elevation: float = 0) → Iterable[Vector]¶ Create polygon vertices for an ellipse with rx as xaxis radius and ry for yaxis radius with count vertices, elevation is the zaxis for all vertices. The ellipse goes from start_param to end_param in counter clockwise orientation.
 Parameters
count – count of polygon vertices
rx – ellipse xaxis radius
ry – ellipse yaxis radius
start_param – start of ellipse in range
0
..2*pi
end_param – end of ellipse in range
0
..2*pi
elevation – zaxis for all vertices
 Returns
vertices in counter clockwise orientation as
Vector
objects

ezdxf.render.forms.
euler_spiral
(count: int, length: float = 1, curvature: float = 1, elevation: float = 0) → Iterable[Vector]¶ Create polygon vertices for an euler spiral of a given length and radius of curvature. This is a parametric curve, which always starts at the origin
(0, 0)
. Parameters
count – count of polygon vertices
length – length of curve in drawing units
curvature – radius of curvature
elevation – zaxis for all vertices
 Returns
vertices as
Vector
objects

ezdxf.render.forms.
ngon
(count: int, length: float = None, radius: float = None, rotation: float = 0., elevation: float = 0., close: bool = False) → Iterable[Vector]¶ Returns the corner vertices of a regular polygon. The polygon size is determined by the edge length or the circum radius argument. If both are given length has higher priority.
 Parameters
count – count of polygon corners >=
3
length – length of polygon side
radius – circum radius
rotation – rotation angle in radians
elevation – zaxis for all vertices
close – yields first vertex also as last vertex if
True
.
 Returns
vertices as
Vector
objects

ezdxf.render.forms.
star
(count: int, r1: float, r2: float, rotation: float = 0., elevation: float = 0., close: bool = False) → Iterable[Vector]¶ Returns corner vertices for star shapes.
Argument count defines the count of star spikes, r1 defines the radius of the “outer” vertices and r2 defines the radius of the “inner” vertices, but this does not mean that r1 has to be greater than r2.
 Parameters
count – spike count >=
3
r1 – radius 1
r2 – radius 2
rotation – rotation angle in radians
elevation – zaxis for all vertices
close – yields first vertex also as last vertex if
True
.
 Returns
vertices as
Vector
objects

ezdxf.render.forms.
gear
(count: int, top_width: float, bottom_width: float, height: float, outside_radius: float, elevation: float = 0, close: bool = False) → Iterable[Vector]¶ Returns gear (cogwheel) corner vertices.
Warning
This function does not create correct gears for mechanical engineering!
 Parameters
count – teeth count >=
3
top_width – teeth width at outside radius
bottom_width – teeth width at base radius
height – teeth height; base radius = outside radius  height
outside_radius – outside radius
elevation – zaxis for all vertices
close – yields first vertex also as last vertex if True.
 Returns
vertices in counter clockwise orientation as
Vector
objects
3D Forms¶
Create 3D forms as MeshTransformer
objects.

ezdxf.render.forms.
cube
(center: bool = True) → MeshTransformer¶ Create a cube as
MeshTransformer
object. Parameters
center – ‘mass’ center of cube,
(0, 0, 0)
ifTrue
, else first corner at(0, 0, 0)
Returns:
MeshTransformer

ezdxf.render.forms.
cylinder
(count: int, radius: float = 1., top_radius: float = None, top_center: Vertex = (0, 0, 1), caps: bool = True) → MeshTransformer¶ Create a cylinder as
MeshTransformer
object, the base center is fixed in the origin (0, 0, 0). Parameters
count – profiles edge count
radius – radius for bottom profile
top_radius – radius for top profile, if
None
top_radius == radiustop_center – location vector for the center of the top profile
caps – close hull with bottom cap and top cap (as Ngons)
Returns:
MeshTransformer

ezdxf.render.forms.
cylinder_2p
(count: int = 16, radius: float = 1, base_center=(0, 0, 0), top_center=(0, 0, 1)) → MeshTransformer¶ Create a cylinder as
MeshTransformer
object from two points, base_center is the center of the base circle and, top_center the center of the top circle. Parameters
count – profiles edge count
radius – radius for bottom profile
base_center – center of base circle
top_center – center of top circle
Returns:
MeshTransformer
New in version 0.11.

ezdxf.render.forms.
cone
(count: int, radius: float, apex: Vertex = (0, 0, 1), caps: bool = True) → MeshTransformer¶ Create a cone as
MeshTransformer
object, the base center is fixed in the origin (0, 0, 0). Parameters
count – edge count of basis
radius – radius of basis
apex – tip of the cone
caps – add a bottom face if
True
Returns:
MeshTransformer

ezdxf.render.forms.
cone_2p
(count: int, radius: float, apex: Vertex = (0, 0, 1)) → MeshTransformer¶ Create a cone as
MeshTransformer
object from two points, base_center is the center of the base circle and apex as the tip of the cone. Parameters
count – edge count of basis
radius – radius of basis
base_center – center point of base circle
apex – tip of the cone
Returns:
MeshTransformer
New in version 0.11.

ezdxf.render.forms.
sphere
(count: int = 16, stacks: int = 8, radius: float = 1, quads = False) → MeshTransformer¶ Create a sphere as
MeshTransformer
object, center is fixed at origin (0, 0, 0). Parameters
count – longitudinal slices
stacks – latitude slices
radius – radius of sphere
quads – use quads for body faces if
True
Returns:
MeshTransformer
New in version 0.11.
3D Form Builder¶

ezdxf.render.forms.
extrude
(profile: Iterable[Vertex], path: Iterable[Vertex], close: bool = True) → MeshTransformer¶ Extrude a profile polygon along a path polyline, vertices of profile should be in counter clockwise order.
 Parameters
profile – sweeping profile as list of
(x, y, z)
tuples in counter clock wise orderpath – extrusion path as list of
(x, y, z)
tuplesclose – close profile polygon if
True
Returns:
MeshTransformer

ezdxf.render.forms.
from_profiles_linear
(profiles: Iterable[Iterable[Vertex]], close: bool = True, caps: bool = False) → MeshTransformer¶ Create MESH entity by linear connected profiles.
 Parameters
profiles – list of profiles
close – close profile polygon if
True
caps – close hull with bottom cap and top cap (as Ngons)
Returns:
MeshTransformer

ezdxf.render.forms.
from_profiles_spline
(profiles: Iterable[Iterable[Vertex]], subdivide: int = 4, close: bool = True, caps: bool = False) → MeshTransformer¶ Create MESH entity by spline interpolation between given profiles. Requires at least 4 profiles. A subdivide value of 4, means, create 4 face loops between two profiles, without interpolation two profiles create one face loop.
 Parameters
profiles – list of profiles
subdivide – count of face loops
close – close profile polygon if
True
caps – close hull with bottom cap and top cap (as Ngons)
Returns:
MeshTransformer

ezdxf.render.forms.
rotation_form
(count: int, profile: Iterable[Vertex], angle: float = 2 * pi, axis: Vertex = (1, 0, 0)) → MeshTransformer¶ Create MESH entity by rotating a profile around an axis.
 Parameters
count – count of rotated profiles
profile – profile to rotate as list of vertices
angle – rotation angle in radians
axis – rotation axis
Returns:
MeshTransformer