Twist-lock cylinder

28 views
Skip to first unread message

Zachary Streeter

unread,
Oct 21, 2024, 4:49:36 PM10/21/24
to CadQuery
Hi folks,

I'd like to create a smoke-detector like object that twists locks to a mounted part on the ceiling. Here is an example video of what I'd like to create

https://www.youtube.com/watch?v=kZBakgFLcew&t=29s&pp=ygUddHdpc3QgbG9jayBtZWNoYW5pc20gM2QgcHJpbnQ%3D

I'm stuck on creating the "L" shape on the side of a cylinder in cadquery.

Appreciate any advice!

Best,
Zachary

Lorenz

unread,
Oct 21, 2024, 7:39:41 PM10/21/24
to CadQuery
 Hi Zachary,

Here is one way to try it.  Note I used features the master branch (free function API).


import cadquery as cq
from cadquery.occ_impl.shapes import *

d1 = 50
d2 = 60
d3 = 70
h = 25
tol1 = 0.2

b1 = (
    cq.Workplane()
    .sketch()
    .circle((d2 - tol1) / 2)
    .circle(d1 / 2, mode="s")
    .finalize()
    .extrude(h)
)

b2 = (
    cq.Workplane()
    .sketch()
    .circle(d3 / 2)
    .circle(d2 / 2, mode="s")
    .finalize()
    .extrude(h)
)


# select the outside face of the inner ring
b1_outside_face = b1.faces("not(%PLANE)").faces(cq.selectors.AreaNthSelector(1)).val()

# select face of the outer ring
b2_inside_face = b2.faces("not(%PLANE)").faces(cq.selectors.AreaNthSelector(0)).val()

f_square = face(
    rect(4, 4).rotate((0, 0, 0), (1, 0, 0), 90).translate((0, 0, h - 10 + 4 / 2))
)

# project the square face to outer ring b2
f_square_proj = f_square.project(b2_inside_face, (0, 1, 0))
# extrude the bump
bump = extrude(f_square_proj, (0, 1, 0))
bumps = [bump] + [bump.rotate((0, 0, 0), (0, 0, 1), a) for a in (90, 180, 270)]
b2 = b2 + compound(bumps)


# create the L shaped face
f_L1 = face(rect(4, 10))
f_L2 = face(rect(10, 4)).translate((-10 / 2 + 4 / 2, -10 / 2 + 4 / 2))
f_L = clean(f_L1 + f_L2)
f_L = f_L.translate((0, -10 / 2)).rotate((0, 0, 0), (1, 0, 0), 90).translate((0, 0, h))

# project the L face to outside face of inner ring
f_L_proj = f_L.project(b1_outside_face, (0, -1, 0))
# create the L shaped cuts
cutL = extrude(f_L_proj, (0, -1, 0))
cutsL = [cutL] + [cutL.rotate((0, 0, 0), (0, 0, 1), a) for a in (90, 180, 270)]
b1 = b1 - compound(cutsL)
Reply all
Reply to author
Forward
0 new messages