Hello, cqMore

November 27, 2021

安裝 cqMore

``````conda install git
``````

``````pip install git+https://github.com/JustinSDK/cqMore
``````

Workplane 擴充

``````from cqmore import Workplane

result = (Workplane()
.rect(10, 10)
.makePolygon(((-2, -2), (2, -2), (2, 2), (-2, 2)))
.extrude(1)
)
``````

``````from cadquery import Workplane
import cqmore
cqmore.extend(Workplane) # 擴充 cqmore.Workplane

result = (Workplane()
.rect(10, 10)
.makePolygon(((-2, -2), (2, -2), (2, 2), (-2, 2)))
.extrude(1)
)
``````

基本使用方式

``````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)
)

solid = Workplane().polyhedron(points, faces)
``````

``````from random import random
from cqmore import Workplane

points = [(random(), random()) for i in range(20)]
convex_hull = Workplane().hull2D(points)
``````

``````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

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)
``````