Define plugins. You may simply use cqmore.Workplane
to replace cadquery.Workplane
. For example:
from cqmore import Workplane
result = (Workplane()
.rect(10, 10)
.makePolygon(((-2, -2), (2, -2), (2, 2), (-2, 2)))
.extrude(1)
)
You may also attach methods of cqmore.Workplane
to cadquery.Workplane
, such as:
from cadquery import Workplane
import cqmore
cqmore.extend(Workplane)
result = (Workplane()
.rect(10, 10)
.makePolygon(((-2, -2), (2, -2), (2, 2), (-2, 2)))
.extrude(1)
)
Signature | Description |
---|---|
makePolygon(points[,forConstruction]) |
Make a multiple sided wire through the provided points. |
intersect2D(toIntersect) |
Intersect the provided wire from the current wire. |
union2D(toUnion) |
Union the provided wire from the current wire. |
cut2D(toCut) |
Cut the provided wire from the current wire. |
hull2D([points,forConstruction]) |
Create a convex hull through the provided points. |
polylineJoin2D(points,join[,forConstruction]) |
Place a join on each point. Hull each pair of joins and union all convex hulls. |
Signature | Description |
---|---|
splineApproxSurface(points[,thickness,combine,clean]) |
Approximate a spline surface through the provided points. |
polyhedron(points,faces[,combine,clean]) |
Create any polyhedron through 3D points(vertices) and faces that enclose the solid. |
hull([points,combine,clean]) |
Create a convex hull through the provided points. |
polylineJoin(points,join[,combine,clean]) |
Place a join on each point. Hull each pair of joins and union all convex hulls. |
Make a multiple sided wire through the provided points.
points
: a list of x,y points make up the polygon.forConstruction = False
: should the new wires be reference geometry only?
from cqmore import Workplane
triangle = Workplane().makePolygon(((-2, -2), (2, -2), (0, 2)))
Intersect the provided wire from the current wire.
toIntersect
: a wire object, or a CQ object having a wire – object to intersect.
from cqmore import Workplane
r1 = Workplane('YZ').rect(10, 10)
r2 = Workplane('YZ').center(5, 5).rect(10, 10)
intersected = r1.intersect2D(r2).extrude(1)
Union the provided wire from the current wire.
toUnion
: a wire object, or a CQ object having a wire – object to union.
from cqmore import Workplane
r1 = Workplane('YZ').rect(10, 10)
r2 = Workplane('YZ').center(5, 5).rect(10, 10)
unioned = r1.union2D(r2).extrude(1)
Cut the provided wire from the current wire.
toCut
: a wire object, or a CQ object having a wire – object to cut.
from cqmore import Workplane
r1 = Workplane('YZ').rect(10, 10)
r2 = Workplane('YZ').center(5, 5).rect(10, 10)
cutted = r1.cut2D(r2).extrude(1)
Create a convex hull through the provided points.
points = None
: a list of x, y points. If it'sNone
, use all pending wires in the parent chain to create a convex hull.forConstruction = False
: should the new wires be reference geometry only?
from random import random
from cqmore import Workplane
points = [(random(), random()) for i in range(20)]
convex_hull = Workplane().hull2D(points)
# an equivalent way
# convex_hull = Workplane().polyline(points).close().hull2D()
Place a join on each point. Hull each pair of joins and union all convex hulls.
points
: a list of x, y points.join
: the wire as a join.forConstruction = False
: should the new wires be reference geometry only?
from cqmore import Workplane
points = [(0, 0), (10, 10), (0, 15), (-10, 10), (-10, 0)]
polyline = Workplane().polylineJoin2D(points, Workplane().polygon(6, 1))
Approximate a spline surface through the provided points.
points
: a 2D list of Vectors that represent the control points.thickness = 0
: the amount of being thick (return 2D surface if 0).combine = False
: should the results be combined with other solids on the stack (and each other)?clean = True
: callclean()
afterwards to have a clean shape.
from cqmore import Workplane
def paraboloid(x, y):
return (x, y, ((y ** 2) - (x ** 2)) / 4)
min_value = -30
max_value = 30
step = 5
thickness = 0.5
points = [[
paraboloid(x / 10, y / 10)
for y in range(min_value, max_value + step, step)
] for x in range(min_value, max_value + step, step)]
surface = Workplane().splineApproxSurface(points, thickness)
Create any polyhedron with 3D points(vertices) and faces that enclose the solid. Each face contains the indices (0 based) of 3 or more points from the points
.
points
: a list of 3D points(vertices).faces
: face indices to fully enclose the solid. When looking at any face from the outside, the face must list all points in a counter-clockwise order.combine = True
: should the results be combined with other solids on the stack (and each other)?clean = True
: callclean()
afterwards to have a clean shape.
from cqmore import Workplane
points = ((5, -5, -5), (-5, 5, -5), (5, 5, 5), (-5, -5, 5))
faces = ((0, 1, 2), (0, 3, 1), (1, 3, 2), (0, 2, 3))
tetrahedron = Workplane().polyhedron(points, faces)
Create a convex hull through the provided points.
points = None
: a list of 3D points. If it'sNone
, attempt to hull all of the items on the stack to create a convex hull.combine = True
: should the results be combined with other solids on the stack (and each other)?clean = True
: callclean()
afterwards to have a clean shape.
from cqmore import Workplane
points = (
(50, 50, 50),
(50, 50, 0),
(-50, 50, 0),
(-50, -50, 0),
(50, -50, 0),
(0, 0, 50),
(0, 0, -50)
)
convex_hull = Workplane().hull(points)
from cqmore import Workplane
from cqmore.polyhedron import uvSphere
convex_hull = (Workplane()
.polyhedron(*uvSphere(10))
.box(20, 20, 5)
.hull()
)
Place a join on each point. Hull each pair of joins and union all convex hulls.
points
: a list of points.join
: the sold as a join.combine = True
: should the results be combined with other solids on the stack (and each other)?clean = True
: callclean()
afterwards to have a clean shape.
from cqmore import Workplane
polyline = (Workplane()
.polylineJoin(
[(0, 0, 0), (10, 0, 0), (10, 0, 10), (10, 10, 10)],
Workplane().box(1, 1, 1)
)
)