# @author Arnaud Morin # SPDX-License-Identifier: Apache-2.0 # import cadquery as cq def lollipop(): # Antenna ant = (cq.Workplane("XZ") .box(15.5, 12.7, 11, centered=(True, True, True)) .fillet(2) ) cut = (cq.Workplane("XZ") .box(13.5, 10.7, 11, centered=(True, True, True))) ant = ant.cut(cut) # tube ant = ant.union( cq.Workplane("YZ") .circle(3.5) .extrude(4.0) .translate((7.75, 0, 0))) # Hole in tube ant = ant.cut( cq.Workplane("YZ") .circle(1.5) .extrude(9.5) .translate((6.5, 0, 0))) # 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), 25) .translate((-8, 0, 7.5))) # Support on standoff sup = (cq.Workplane("XY") .polyline([ (-3, 0), (-3, -4), (-0.5, -14), (4.2, -13), (1, -9), (0, 0), ]).close() .mirrorX() .extrude(3/2, both=True) ) sup2 = (cq.Workplane("XY") .pushPoints([(2, 14), (2, -14)]) .circle(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) 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))