Converted a few more examples.
This commit is contained in:
parent
fed83573f2
commit
e31b95099f
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 <XY selector.
|
||||
# 3c. A new workplane is created on the vertex to build future geometry on.
|
||||
result = result.faces(">Z").vertices("<XY").workplane()
|
||||
|
||||
# Cut the corner out
|
||||
# 4. A circle is drawn with the selected vertex as its center.
|
||||
# 4a. The circle is cut down through the box to cut the corner out.
|
||||
result = result.circle(1.0).cutThruAll()
|
||||
|
||||
# Render the solid
|
||||
show(result)
|
||||
# Displays the result of this script
|
||||
show_object(result)
|
||||
|
|
|
@ -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
|
||||
|
||||
# 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 geometry based off it later.
|
||||
result = cq.Workplane("front").box(3, 2, 0.5)
|
||||
|
||||
# Workplane is offset from the object surface
|
||||
# 3. The lowest face in the X direction is selected with the <X selector.
|
||||
# 4. A new wokrplane is created
|
||||
# 4a.The workplane is offset from the object surface so that it is not touching
|
||||
# the original box.
|
||||
result = result.faces("<X").workplane(offset=0.75)
|
||||
|
||||
# Create a disc
|
||||
# 5. Creates a thin disc on the offset workplane that is floating near the box.
|
||||
result = result.circle(1.0).extrude(0.5)
|
||||
|
||||
# Render the solid
|
||||
show(result)
|
||||
# Displays the result of this script
|
||||
show_object(result)
|
||||
|
|
|
@ -1,13 +1,22 @@
|
|||
# This example is meant to be used from within the CadQuery module of FreeCAD.
|
||||
import cadquery
|
||||
from Helpers import show
|
||||
import cadquery as cq
|
||||
|
||||
# Create a rotated workplane and put holes in each corner of a rectangle on
|
||||
# that workplane, producing angled holes in the face
|
||||
result = cadquery.Workplane("front").box(4.0, 4.0, 0.25).faces(">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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user