Forms

Basic Forms

ezdxf.addons.circle(count, radius=1, elevation=0, close=False)

Create polygon vertices for a circle with radius and count vertices.

Parameters:
  • count – count of polygon vertices
  • radius – circle radius
  • elevation – z axis for all vertices
  • close – yields first vertex also as last vertex if True.
Returns:

yields Vector objects in counter clockwise orientation

ezdxf.addons.ellipse(count, rx=1, ry=1, start_param=0, end_param=2*pi, elevation=0)

Create polygon vertices for an ellipse with rx as x-axis radius and ry for y-axis radius with count vertices. The curve goes from start_param to end_param in counter clockwise orientation.

Parameters:
  • count – count of polygon vertices
  • rx – ellipse x-axis radius
  • ry – ellipse y-axis radius
  • start_param – start of ellipse in range 0 … 2*pi
  • end_param – end of ellipse in range 0 … 2*pi
  • elevation – z axis for all vertices
Returns:

yields Vector objects

ezdxf.addons.euler_spiral(count, length=1, curvature=1, elevation=0)

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.

Parameters:
  • count – count of polygon vertices
  • length – length of curve in drawing units
  • curvature – radius of curvature
  • elevation – z-axis for all vertices
Returns:

yields Vector objects

ezdxf.addons.cube(center=True, matrix=None)

Create a cube.

Parameters:
  • matrix – transformation matrix as Matrix44
  • center – ‘mass’ center of cube in (0, 0, 0) if True, else first corner at (0, 0, 0)
Returns:

MeshBuilder

ezdxf.addons.cylinder(count, radius=1., top_radius=None, top_center=(0, 0, 1), caps=True)

Create a cylinder.

Parameters:
  • count – profiles edge count
  • radius – radius for bottom profile
  • top_radius – radius for top profile, same as radius if top_radius is None
  • top_center – location vector for the center of the top profile
  • caps – close hull with bottom cap and top cap (as N-gons)
Returns:

MeshVertexMerger

ezdxf.addons.cone(count, radius, apex=(0, 0, 1), caps=True)

Create a cone.

Parameters:
  • count – edge count of basis
  • radius – radius of basis
  • apex – apex of the cone
  • caps – add a bottom face if true
Returns:

MeshVertexMerger

Form Builder

ezdxf.addons.extrude(profile, path, close=True)

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 order
  • path – extrusion path as list of (x, y, z) tuples
  • close – close profile polygon if True
Returns:

MeshVertexMerger

ezdxf.addons.from_profiles_linear(profiles, close=True, caps=False)

Mesh 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 N-gons)
Returns:

MeshVertexMerger

ezdxf.addons.from_profiles_spline(profiles, subdivide=4, close=True, caps=False)

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 N-gons)
Returns:

MeshVertexMerger

ezdxf.addons.rotation_form(count, profile, angle=2*pi, axis=(1, 0, 0))

Mesh 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:

MeshVertexMerger

MengerSponge

Build a 3D Menger sponge.

class ezdxf.addons.MengerSponge
MengerSponge.__init__(location=(0, 0, 0), length=1., level=1, kind=0)
Parameters:
  • location – location of lower left corner as (x, y, z) tuple
  • length – side length
  • level – subdivide level
  • kind

    type of menger sponge:

    • 0 = original menger sponge
    • 1 = Variant XOX
    • 2 = Variant OXO
    • 3 = Jerusalem Cube
MengerSponge.render(layout, merge=False, dxfattribs=None, matrix=None)

Renders the menger sponge into layout, set merge == True for rendering the whole menger sponge into one Mesh entity, set merge to False for rendering the individual cubes of the menger sponge as Mesh entities.

Parameters:
  • layout – ezdxf Layout object
  • mergeTrue for one Mesh entity, False for individual Mesh entities per cube
  • dxfattribs – dict of DXF attributes e.g. {‘layer’: ‘mesh’, ‘color’: 7}
  • matrix – transformation matrix as Matrix44
MengerSponge.cubes()

Generates all cubes of the menger sponge as individual MeshBuilder objects.

MengerSponge.mesh()

Returns geometry as one MeshVertexMerger entity.

SierpinskyPyramid

Build a 3D Sierpinsky Pyramid.

class ezdxf.addons.SierpinskyPyramid
SierpinskyPyramid.__init__(location=(0, 0, 0), length=1., level=1, sides=4)
Parameters:
  • location – location of base center as (x, y, z) tuple
  • length – side length
  • level – subdivide level
  • sides – sides of base geometry
SierpinskyPyramid.render(layout, merge=False, dxfattribs=None, matrix=None)

Renders the sierpinsky pyramid into layout, set merge == True for rendering the whole sierpinsky pyramid into one Mesh entity, set merge to False for rendering the individual pyramids of the sierpinsky pyramid as Mesh entities.

Parameters:
  • layout – ezdxf Layout object
  • mergeTrue for one Mesh entity, False for individual Mesh entities per cube
  • dxfattribs – dict of DXF attributes e.g. {‘layer’: ‘mesh’, ‘color’: 7}
  • matrix – transformation matrix as Matrix44
SierpinskyPyramid.pyramids()

Generates all pyramids of the sierpinsky pyramid as individual MeshBuilder objects.

SierpinskyPyramid.mesh()

Returns geometry as one MeshVertexMerger entity.