示例#1
0
    for d in dims.inlet, dims.outlet:
        part = (cq.Workplane("XY").circle(d.fitting.min / 2 + d.thick / 4).
                workplane(offset=d.fitting.length).circle(d.fitting.max / 2 +
                                                          d.thick / 4).loft())

        taper = (cq.Workplane("XY").circle(d.fitting.min / 2).workplane(
            offset=d.fitting.length).circle(d.fitting.max / 2).loft())

        part = part.cut(taper)

        parts.append(part)
    return parts


cs.clear()
dims = cs.Dims('scripts/shop/vacbaffle/vacbaffle.yml')

# Some calculated dimensions.
dims.bucket.slope = (dims.bucket.topdia -
                     dims.bucket.botdia) / (2 * dims.bucket.height)

# Applying fudge factors.
dims.outlet.fitting.max += dims.outlet.fitting.fudge
dims.outlet.fitting.min += dims.outlet.fitting.fudge
dims.inlet.fitting.max += dims.inlet.fitting.fudge
dims.inlet.fitting.min += dims.inlet.fitting.fudge

if dims.get('debug', False):
    inlet, outlet = build_debug(dims)
    inlet.val().label = "test-inlet"
    outlet.val().label = "test-outlet"
示例#2
0
"""A set of clips to hold up the gym mirror."""

import cadquery as cq
import caddyshack as cs

dims = cs.Dims('scripts/gym/mirror-clips.yml')
clip = dims.clip

# Add an extra 1/2 standoff for the cap on top.
clip.height = clip.standoff * 1.5 + dims.mirror
clip.depth = dims.screw.head * 2 + clip.overhang

part = (cq.Workplane("XY").box(
    clip.width, clip.depth, clip.height).edges("|Z").fillet(3 * clip.fillet))

part = (part.faces(">Y").workplane(invert=True).move(
    0, -clip.height / 2 + dims.mirror / 2 + clip.standoff / 2).rect(
        clip.width, dims.mirror).cutBlind(clip.overhang))

part = (part.faces(">Z").workplane().move(
    0, -1 / 2 * clip.depth + dims.screw.head).cskHole(dims.screw.clearance,
                                                      dims.screw.head, 82))

# Should technically be able to do scew_head/2, but the cskHole oversinks
# by a good bit it seems.
part = part.edges(">Z").fillet(min(clip.fillet, dims.screw.head / 3))

# Fin.
cs.showsave(part, dims=dims)
示例#3
0
        .faces(">Z[-2]").workplane(
            offset=-dims.thick /
            2).circle(dims.mount.dia / 2 +
                      dims.thick).extrude(dims.mount.length + dims.thick /
                                          2).faces(">Z").workplane().hole(
                                              dims.mount.dia)

        # Put the grub screw pilot at half height.
        .faces(">Z").workplane(offset=-dims.mount.length / 2).transformed(
            rotate=(90, 0, 0)).circle(dims.pilot / 2).cutBlind(dims.mount.dia +
                                                               dims.thick)

        # Now add holes for the zip ties.
        # Space them dims.thick apart (eh, because), and import the
        # entirety of numpy for one f*****g function since the range builtin only does ints.
        .faces("<Y[1]").workplane().pushPoints([
            (s * x, 0) for s in (1, -1)
            for x in np.arange(dims.mount.dia / 2 +
                               dims.thick * 1.5, dims.holder.length / 2 -
                               dims.thick / 2, dims.thick)
        ]).hole(dims.pilot))

    return result


cs.clear()

dims = cs.Dims('scripts/household/watchwind.yml')
obj = build(dims)
cs.showsave(obj, dims)
示例#4
0
    # following that with a union would swallow the hole... we start
    # by cutting it all out, then cutting the hole, then putting it back.
    # lolwhut
    standoff = standoff.cut(holepart)
    holepart = getattr(
        (holepart.faces(">Z").workplane()),
        holefunc)(*holeargs)  # This is where I kinda wish hole() alone
    # had copious kwargs.

    standoff = standoff.union(holepart)
    return standoff


cs.clear()

dims = cs.Dims('scripts/electronics/standoff.yml')
ds = dims.standoff
dw = dims.wireclamp

# Calculate buffer for the holes.
if dims.countersunk:
    hbuffer = (dims.countersunk) * 1.1
else:
    hbuffer = (dims.pilot) * 1.75

for tname, toe in ds.toe.items():
    for hname, height in ds.heights.items():
        # First build the bottom part:
        standoff = build_standoff(toe, height, ds.thick, hbuffer,
                                  dims.clearance, None)
        standoff.val().label = "%s-%s" % (tname, hname)
示例#5
0
import cadquery as cq
import caddyshack as cs

def build(dims):
    # Dividing these parts up so we can select things separately and fillet...
    # Selectors make it easy to select lots of things, but sometimes harder
    # if you don't want to select *all the things.*

    block = cq.Workplane("XY").box(dims.width, dims.depth, dims.height)
    filleted = copy(block).edges("<Z or |Z").fillet(dims.fillets.edges)

    prongs = (block
                .faces(">Z")
                .workplane()
                .pushPoints([(-dims.prongs.spacing/2,0),(dims.prongs.spacing/2,0)])
                .rect(dims.prongs.thickness, dims.prongs.width)
                .extrude(-dims.prongs.length, combine=False)
                )

    block = (block.cut(prongs).edges("|Y").fillet(dims.fillets.prongs))
    return block.intersect(filleted)

def copy(obj):
    # A gross hack.
    return obj.translate((0, 0, 0))

cs.clear()
dims = cs.Dims('scripts/electronics/plugcover.yml')
obj = build(dims)
cs.showsave(obj, dims)
示例#6
0
"""Builds a puck that can house an array of magnets to use as a
rotary demagnetizing tool.

As in: https://www.youtube.com/watch?v=10enFh_OXZg
"""

import cadquery as cq
import caddyshack as cs

cs.clear()

dims = cs.Dims("scripts/shop/magnets/demag-tool.yml")

# Apply the fudge factors.
dims.bolt.wrench = dims.bolt.wrench * (1 + dims.bolt.fudge)
dims.mag.size = dims.mag.size + dims.mag.fudge

# Build the puck with the bolt hole.
part = (cq.Workplane("XY").circle(dims.dia / 2).extrude(
    dims.base).edges().fillet(dims.fillet).faces(">Z").workplane().polygon(
        6, cs.geometry.circumscribe(n=6, wrench=dims.bolt.wrench)).cutBlind(
            -dims.bolt.cap).faces("<Z").workplane().hole(dims.bolt.pilot))

# Make each slot for the array, then cut them out.
slots = []
for i in range(dims.array.N):
    # Move the workplane to the appropriate spot.
    # Not using a polygon with .vertices() because we need the rotation too.
    slot = (part.faces(">Z").workplane().transformed(
        (0, 0, 360 / dims.array.N * i)).transformed(
            (0, 0, 0), (dims.array.dia / 2, 0, 0)))
示例#7
0
    bradius = cs.geometry.circumscribe(n=6,
                                       apo=bolt.wrench / 2) * (1 + bolt.fudge)
    hole = bolt.dia * (1 + bolt.fudge)

    # Start with the bare polygon.
    knob = (cq.Workplane("XY").polygon(dk.points, radius).extrude(height))

    # Make a cutout at each vertex, preserving the flats between them.
    knob = (knob.vertices().hole(2 * radius / dk.points))
    # Fillet edges.
    knob = knob.edges("|Z").fillet(radius / (2 * dk.points) * dk.size.roundoff)
    knob = knob.faces(">Z").fillet(rover)

    # Make the hex bolt hole.
    knob = (knob.faces(">Z").workplane().polygon(
        6, bradius).cutBlind(-height +
                             support).faces("<Z").workplane().hole(hole))

    return knob


cs.clear()

dims = cs.Dims('scripts/misc/boltknob.yml')

for name, bolt in dims.bolts.items():
    obj = build_knob(dims, bolt)
    obj.val().label = "n%d-%s" % (dims.knob.points,
                                  urllib.parse.quote(name, safe=""))
    cs.showsave(obj, dims)
示例#8
0
    return indicator


def build_spacer(dims, width):
    d = dims.spacer
    spacer = (cq.Workplane("XY").rect(
        dims.tube.size,
        d.oncenter * 2).extrude(width).faces(">Z").workplane().pushPoints([
            (0, d.oncenter / 2), (0, -d.oncenter / 2)
        ]).hole(d.pilot).edges("|Z").fillet(d.pilot).edges("not(|Z)").fillet(
            d.fillet))
    return spacer


dims = cs.Dims('scripts/bikes/truing-stand/dimensions.yml')

names = ['bracket', 'indicator', 'slider']
for name in names:
    obj = globals()["build_" + name](dims)  # oh god
    obj.val().label = name
    cs.showsave(obj, dims)

# This is one example of where the list->dict conversion rears its head. Blarg.
for width in dims.spacer.widths.values():
    obj = build_spacer(dims, width)
    obj.val().label = "spacer-%d" % width
    doc = cs.showsave(obj, dims)

    # Hack. Because we don't need to see *all* the spacers.
    import FreeCAD
示例#9
0
    lav = (
        base.faces(">Z").workplane().move(
            0, dims.base.length * dims.lav.position).rect(
                dims.lav.width, dims.lav.length).extrude(
                    dims.lav.height, combine=False).edges("|Y and >Z").fillet(
                        dims.lav.fillet).faces(">Y").workplane()

        # Move so that 1/3 of the hole is dropped, so you get a semi-springy
        # clip thing that doesn't just drop the mic (or walk away).
        .transformed(offset=(0, dims.lav.height / 2 - dims.lav.hole * 0.33,
                             0)).cskHole(dims.lav.hole,
                                         dims.lav.hole * (1 + dims.lav.taper),
                                         angle))

    wire = (base.faces(">Z").workplane().move(
        0, -dims.base.length * dims.wire.position).rect(
            dims.wire.width, dims.wire.length).extrude(
                dims.wire.height, combine=False).edges("|Y and >Z").fillet(
                    dims.wire.fillet).faces(">Z").workplane().rect(
                        dims.wire.slot.width,
                        dims.wire.length).cutBlind(-dims.wire.slot.depth))

    return base.union(lav).union(wire)


cs.clear()

dims = cs.Dims('scripts/misc/lavmic-clip.yml')
obj = build(dims)
cs.showsave(obj, dims)
示例#10
0
Note that the magnets should be inserted such that the field
points along the border and separator lines, not along the
open faces of the fixture.
"""

import cadquery as cq
import caddyshack as cs

dims = cs.Dims("""
output:
    basename: linear-halbach
    baseunit: mm

border: 0.125 in  # thickness for the 4 perimeter walls
sep: 0.0625 in    # thickness for the seperators between magnets

N: 9              # number of magnets
mag: 10.4 mm      # slip-fit for 10mm cube magnet

fillet: 0.02 in   # taking the edge off
""")

cs.clear()

# Calculate the overall size.
L = dims.mag * dims.N + (dims.N - 1) * dims.sep + 2 * dims.border
W = dims.mag + 2 * dims.border

# Make the main body of the fixture.
part = cq.Workplane("XY").box(L, W, dims.mag, centered=(False, True, False))
示例#11
0
"""Builds a tool for adjusting Mavic UST rim splined nipples and for holding
bladed spokes.
"""

import cadquery as cq
import caddyshack as cs

cs.clear()
dims = cs.Dims("scripts/bikes/mavic-spline.yml")

# This part is basically yanked from my boltknob script.
radius = cs.geometry.circumscribe(n=dims.knob.N, apo=dims.knob.size / 2)

knob = (
    cq.Workplane("XY").polygon(dims.knob.N, radius).extrude(
        dims.knob.base).vertices().hole(2 * radius / dims.knob.N).edges(
            "|Z").fillet(radius / (2 * dims.knob.N) * 0.99).faces("#Z").fillet(
                dims.knob.fillet).faces(">Z").workplane().circle(
                    radius=dims.nipple.dia *
                    1.5)  # Make significantly larger than the nipple itself.
    .extrude(dims.knob.stickout))

# Slit for sliding along a bladed spoke.
slit = (cq.Workplane("XZ").move(
    0, (dims.knob.base + dims.knob.stickout) / 2).rect(
        dims.spoke.thick,
        dims.knob.base + dims.knob.stickout).extrude(dims.knob.size))

# Bladed spoke holder.
blade = (cs.copy(knob).cut(slit))