132 lines
2.9 KiB
Python
132 lines
2.9 KiB
Python
# @author Arnaud Morin <arnaud.gfpv@mailops.fr>
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
import cadquery as cq
|
|
|
|
|
|
def lollipop():
|
|
|
|
# Antenna
|
|
ant = (cq.Workplane("XZ")
|
|
.box(17, 15, 11, centered=(True, True, True))
|
|
.fillet(1)
|
|
)
|
|
|
|
|
|
cut = (cq.Workplane("XZ")
|
|
.box(13.5, 10.7, 11, centered=(True, True, True)))
|
|
|
|
ant = ant.cut(cut)
|
|
|
|
# Add mass around the tube
|
|
mass = (cq.Workplane("XZ")
|
|
.polyline([
|
|
(0, 0),
|
|
(2, 0),
|
|
(13, 12),
|
|
(0, 12),
|
|
])
|
|
.close()
|
|
.extrude(10)
|
|
.fillet(1)
|
|
.translate((7, 5, -6)))
|
|
|
|
ant = ant.union(mass)
|
|
|
|
# Insert in tube
|
|
ant = ant.cut(
|
|
cq.Workplane("YZ")
|
|
.circle(2.5)
|
|
.extrude(4)
|
|
.translate((6.75, 0, 0)))
|
|
|
|
# Fillet on insert
|
|
ant = ant.edges(
|
|
cq.selectors.BoxSelector((6.5, -3, -3), (7.0, 3, 3))).fillet(1.0)
|
|
|
|
# Rotate and translate
|
|
ant = (ant.rotate((0, 0, 0), (0, 1, 0), 45)
|
|
.translate((-8, 0, 9.5)))
|
|
|
|
# Support on standoff
|
|
sup = (cq.Workplane("XY")
|
|
.polyline([
|
|
(-3, -3),
|
|
(-0.5, -14),
|
|
(4.2, -13),
|
|
(2, -9),
|
|
(2, -3),
|
|
]).close()
|
|
.mirrorX()
|
|
.extrude(4, both=True)
|
|
.translate((0,0,1))
|
|
)
|
|
|
|
sup2 = (cq.Workplane("XY")
|
|
.pushPoints([(2, 14), (2, -14)])
|
|
.circle(6.5/2)
|
|
.extrude(5, both=True))
|
|
|
|
sup = sup.union(sup2)
|
|
|
|
cut = (cq.Workplane("XY")
|
|
.pushPoints([(2, 14), (2, -14)])
|
|
.circle(3.5/2)
|
|
.extrude(5, both=True))
|
|
sup = sup.cut(cut)
|
|
|
|
p = ant.union(sup)
|
|
|
|
# Cut to have a flat printable object
|
|
cut = (cq.Workplane("XY")
|
|
.box(50, 50, 30, centered=(True, True, False))
|
|
.translate((0,0,-30))
|
|
)
|
|
p = p.cut(cut)
|
|
|
|
# Cut to reduce weight
|
|
cut = (cq.Workplane("XY")
|
|
.box(50, 15, 30, centered=(False, True, True))
|
|
.translate((2,0,0))
|
|
)
|
|
|
|
p = p.cut(cut)
|
|
|
|
# Translate back to ease next cut and hole
|
|
p = (p.rotate((0, 0, 0), (0, 1, 0), -45)
|
|
.translate((0, 0, -1)))
|
|
|
|
# Hole in tube
|
|
p = p.faces("<X").workplane().hole(2)
|
|
|
|
# Split half
|
|
cut = (cq.Workplane("XY")
|
|
.box(50, 1, 20, centered=(True, True, True))
|
|
.translate((0,0,-10))
|
|
)
|
|
p = p.cut(cut)
|
|
|
|
# Translate back to ease assembly
|
|
p = (p.rotate((0, 0, 0), (0, 1, 0), 45)
|
|
.translate((0, 0, 1)))
|
|
|
|
return p
|
|
|
|
|
|
result = lollipop()
|
|
|
|
assert result.solids().size() == 1, "lollipop is not one solid"
|
|
|
|
if "show_object" not in globals(): # running outside CQ-editor
|
|
def show_object(*args, **kwargs):
|
|
pass
|
|
|
|
show_object(result)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
TPU_DENSITY = 1.21e-3 # g/mm3
|
|
|
|
print("lollipop %.2f g in TPU" % (result.val().Volume() * TPU_DENSITY))
|