FoundationPartsSketchesFirst Sketch

Your First Sketch

2D Sketches are often the first step in making a 3D operation. Extrusions, and Lathe all start with a 2D sketch.

To create a sketch, you can use the Sketch class. You will need to specify the plane that the sketch will be on. As a starting Point you can use the origin planes that can access using part.xy(), part.yz(), and part.xz().

As you saw in the first example, on a Sketch you can create Points and Lines.

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

l1 = Line(p1, p2) l2 = Line(p2, p3) l3 = Line(p3, p4) l4 = Line(p4, p1)

You can also use the sketch.pencil to make it easier to draw lines.

We can also use the pencil attribute of the Sketch. The pencil object has methods for moving in absolute coordinates (move_to) as well as relatively (move) and drawing lines (line_to), which are used in a loop to draw the star shape. Once the shape is drawn, you can extract the Polygon using the get_closed_polygon.

As you can see we are also using import numpy as np to perform maths operations.

You can also use many tools to create more complex Sketches. Extrusion require a closed shape but you can make use of many of the already available shapes:

  • Rectangle
  • Square
  • Circle
  • Ellipse
  • Hexagon
  • Polygon