代码拉取完成,页面将自动刷新
import cadquery as cq
from cadquery import exporters
import math
resc_parameters = [
# size x, size y, pad x, pad y, pad center-center, grid x, grid y, terminal x, heights
(10, 5, 0.90, 0.70, 1.30, 6, 2, (0.10, 0.30), [15, 35, 37, 40]),
(16, 8, 1.10, 1.00, 1.70, 6, 4, (0.15, 0.40), [40]),
(20, 12, 1.30, 1.50, 1.90, 8, 4, (0.15, 0.65), [40]),
(32, 16, 1.60, 1.80, 2.80, 10, 4, (0.25, 0.75), [40]),
(32, 25, 1.60, 2.70, 2.80, 10, 6, (0.25, 0.75), [40]),
(50, 25, 1.80, 2.70, 4.40, 14, 6, (0.35, 0.85), [40]),
(63, 32, 1.80, 3.20, 5.60, 16, 8, (0.35, 0.85), [40]),
]
(sx, sy, px, py, pcc, gx, gy, tx, heights) = resc_parameters[0]
sx = float(sx)/10
sy = float(sy)/10
tx = (tx[0] + tx[1]) / 2
h = heights[1]
h = float(h) / 100
th = h * 0.05
body = cq.Workplane("XZ").\
moveTo(-sx/2 + th, th).\
lineTo(-sx/2 + th, h - th).\
lineTo(sx/2 - th, h - th).\
lineTo(sx/2 - th, th).\
close().\
extrude(sy).\
translate((0, sy/2, 0))
show_object(body)
top = cq.Workplane("XZ").\
moveTo(-sx/2 + tx, h - th).\
lineTo(-sx/2 + tx, h).\
lineTo(sx/2 - tx, h).\
lineTo(sx/2 - tx, h - th).\
close().\
extrude(sy).\
translate((0, sy/2, 0))
show_object(top)
f = math.sqrt(2)/2 * th
def terminal():
return cq.Workplane("XZ").\
moveTo(-sx/2 + tx, 0).\
lineTo(-sx/2 + th, 0).\
threePointArc((-sx/2 + th - f, th - f), (-sx/2, th)).\
lineTo(-sx/2, h - th).\
threePointArc((-sx/2 + th - f, h - th + f), (-sx/2 + th, h)).\
lineTo(-sx/2 + tx, h).\
lineTo(-sx/2 + tx, h - th).\
lineTo(-sx/2 + th, h - th).\
lineTo(-sx/2 + th, th).\
lineTo(-sx/2 + tx, th).\
close().\
extrude(sy).\
translate((0, sy/2, 0))
end = terminal()
show_object(end)
start = terminal().\
rotate((0, 0, -1), (0, 0, 1), 180)
show_object(start)
if False:
with open("/tmp/wat.step", "w") as f:
objects = [body, top, end, start]
# objects = cq.Workplane("XY").union([body, top, end, start])
o = body.union(top)
cq.exporters.exportShape(o, "STEP", f)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。