cadquery icon indicating copy to clipboard operation
cadquery copied to clipboard

Mating two gears with teeth

Open lenianiva opened this issue 8 months ago • 3 comments

I have two gears that have teeth on them:

image

How would I make tagged objects and constraints so that the gears will mesh? Ideally I want to supply two values for this assembly:

  1. The offset, which specifies how far apart the gears should be
  2. The angle, which specifies the relative angles between the two gears along their axes Is there a way to do this? I tried to tag a circle wire that is forConstruction but wires cannot be used as axis or plane constraints.
import cadquery as Cq

base_height = 60
radius = 60;
radius_centre = 30
radius_inner = 40
n_tooth = 10
def create():
    teeth = (
        Cq.Workplane("XY")
        .polarArray(radius=radius_inner, startAngle=0, angle=360, count=n_tooth)
        .eachpoint(lambda loc: Cq.Solid.makeBox(radius - radius_inner, 2, 2).located(loc))
        .union()
    )
    base = (
        Cq.Workplane('XY')
        .cylinder(
            height=base_height,
            radius=radius,
            centered=(True, True, False))
        .cylinder(
            height=base_height,
            radius=radius_centre,
            combine='s',
            centered=(True, True, True))
        .union(teeth.val().move(0, 0, base_height))
    )
    base.faces(">Z").tag("mate")
    return base

obj1 = create()
obj2 = create()
result = (
    Cq.Assembly()
    .add(obj1, name="obj1", color=Cq.Color(0.8,0.8,0.5,0.3))
    .add(obj2, name="obj2", color=Cq.Color(0.5,0.5,0.5,0.3), loc=Cq.Location(0,0,40))
    .constrain("obj1?mate", "obj2?mate", "Plane")
    .solve()
)
show_object(result)

lenianiva avatar Jun 19 '24 22:06 lenianiva