Skip to content

Creating Filled Stadiums #1193

Answered by mozman
johnthagen asked this question in Q&A
Nov 6, 2024 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

A HATCH entity to get the filling, a LWPOLYLINE entity to get the border line if required.

import ezdxf
from ezdxf.layouts import Modelspace

def add_stadium_as_lwpolyline(msp: Modelspace, a: float, r: float) -> None:
    # format: x, y, bulge
    # bulge value always at the start vertex of the arc
    d = 2 * r
    points = [
        (0, 0, 0),
        (0, a, 1),  # semi-circle follows
        (-d, a, 0),
        (-d, 0, 1),  # semi-circle follows
        # close shape
    ]
    msp.add_lwpolyline(points, format="xyb", close=True)


def add_stadium_as_hatch(msp: Modelspace, a: float, r: float) -> None:
    d = 2 * r
    hatch = msp.add_hatch(color=1)
    edges = hatch.paths.add_edge_path(…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@johnthagen
Comment options

@mozman
Comment options

Answer selected by johnthagen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants