Foundation (Python)How-to guidesDraw a custom closed shape

Draw a custom closed shape

If you want to increase the complexity of the shapes you draw on Sketch, you can use the CustomClosedShape class.

This class allows you to create a shape using a list of Line | Arc objects.

In this example, we are creating a half circle using one Line and one Arc.

Renders the 3D model in your browser. The first run downloads the Python runtime (≈30 MB).
from cadbuildr.foundation import *

half_circle = Part()
s = Sketch(half_circle.xy())

p1 = Point(s, 0, 0)
p2 = Point(s, 40, 0)
p3 = Point(s, 20, 20)

l1 = Line(p1, p2)
a1 = Arc(p2, p3, p1)

custom = CustomClosedShape([l1, a1])
e = Extrusion(custom, 10)
half_circle.add_operation(e)
show(half_circle)

you can also use the sketch.pencil to make it easier to draw lines and arcs.

Renders the 3D model in your browser. The first run downloads the Python runtime (≈30 MB).
from cadbuildr.foundation import *

half_circle = Part()
s = Sketch(half_circle.xy())

s.pencil.line_to(40, 0)
s.pencil.arc_to(0, 0, -20)

custom = s.pencil.get_closed_shape()
e = Extrusion(custom, 10)
half_circle.add_operation(e)
show(half_circle)