diff --git a/Examples/Ex011_Mirroring_Symmetric_Geometry.py b/Examples/Ex011_Mirroring_Symmetric_Geometry.py index a34a46d..2fc1092 100644 --- a/Examples/Ex011_Mirroring_Symmetric_Geometry.py +++ b/Examples/Ex011_Mirroring_Symmetric_Geometry.py @@ -1,15 +1,20 @@ -# This example is meant to be used from within the CadQuery module of FreeCAD. -import cadquery -from Helpers import show +import cadquery as cq -# 1.0 is the distance, not coordinate -r = cadquery.Workplane("front").hLine(1.0) +# 1. Establishes a workplane that an object can be built on. +# 1a. Uses the named plane orientation "front" to define the workplane, meaning +# that the positive Z direction is "up", and the negative Z direction +# is "down". +# 2. A horizontal line is drawn on the workplane with the hLine function. +# 2a. 1.0 is the distance, not coordinate. hLineTo allows using xCoordinate +# not distance. +r = cq.Workplane("front").hLine(1.0) -# hLineTo allows using xCoordinate not distance +# 3. Draw a series of vertical and horizontal lines with the vLine and hLine +# functions. r = r.vLine(0.5).hLine(-0.25).vLine(-0.25).hLineTo(0.0) -# Mirror the geometry and extrude +# 4. Mirror the geometry about the Y axis and extrude it into a 3D object. result = r.mirrorY().extrude(0.25) -# Render the solid -show(result) +# Displays the result of this script +show_object(result) diff --git a/Examples/Ex012_Creating_Workplanes_on_Faces.py b/Examples/Ex012_Creating_Workplanes_on_Faces.py index 70ef1da..d73fafe 100644 --- a/Examples/Ex012_Creating_Workplanes_on_Faces.py +++ b/Examples/Ex012_Creating_Workplanes_on_Faces.py @@ -1,12 +1,16 @@ -# This example is meant to be used from within the CadQuery module of FreeCAD. -import cadquery -from Helpers import show +import cadquery as cq -# Make a basic prism -result = cadquery.Workplane("front").box(2, 3, 0.5) +# 1. Establishes a workplane that an object can be built on. +# 1a. Uses the named plane orientation "front" to define the workplane, meaning +# that the positive Z direction is "up", and the negative Z direction +# is "down". +# 2. Creates a 3D box that will have a hole placed in it later. +result = cq.Workplane("front").box(2, 3, 0.5) -# Find the top-most face and make a hole +# 3. Find the top-most face with the >Z max selector. +# 3a. Establish a new workplane to build geometry on. +# 3b. Create a hole down into the box. result = result.faces(">Z").workplane().hole(0.5) -# Render the solid -show(result) +# Displays the result of this script +show_object(result) diff --git a/Examples/Ex013_Locating_a_Workplane_on_a_Vertex.py b/Examples/Ex013_Locating_a_Workplane_on_a_Vertex.py index dc7721a..197e5c0 100644 --- a/Examples/Ex013_Locating_a_Workplane_on_a_Vertex.py +++ b/Examples/Ex013_Locating_a_Workplane_on_a_Vertex.py @@ -1,15 +1,21 @@ -# This example is meant to be used from within the CadQuery module of FreeCAD. -import cadquery -from Helpers import show +import cadquery as cq -# Make a basic prism -result = cadquery.Workplane("front").box(3, 2, 0.5) +# 1. Establishes a workplane that an object can be built on. +# 1a. Uses the named plane orientation "front" to define the workplane, meaning +# that the positive Z direction is "up", and the negative Z direction +# is "down". +# 2. Creates a 3D box that will have a hole placed in it later. +result = cq.Workplane("front").box(3, 2, 0.5) -# Select the lower left vertex and make a workplane +# 3. Select the lower left vertex and make a workplane. +# 3a. The top-most Z face is selected using the >Z selector. +# 3b. The lower-left vertex of the faces is selected with the Z").vertices("Z") \ +# 1. Establishes a workplane that an object can be built on. +# 1a. Uses the named plane orientation "front" to define the workplane, meaning +# that the positive Z direction is "up", and the negative Z direction +# is "down". +# 2. Creates a plain box to base future geometry on with the box() function. +# 3. Selects the top-most Z face of the box. +# 4. Creates a new workplane and then moves and rotates it with the +# transformed function. +# 5. Creates a for-construction rectangle that only exists to use for plancing +# other geometry. +# 6. Selects the vertices of the for-construction rectangle. +# 7. Places holes at the center of each selected vertex. +# 7a. Since the workplane is rotated, this results in angled holes in the face. +result = cq.Workplane("front").box(4.0, 4.0, 0.25).faces(">Z") \ .workplane() \ .transformed(offset=(0, -1.5, 1.0), rotate=(60, 0, 0)) \ .rect(1.5, 1.5, forConstruction=True).vertices().hole(0.25) -# Render the solid -show(result) +# Displays the result of this script +show_object(result)