Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove polyline/extrude, and just create a box. #105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions src/dactyl_manuform.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,15 +363,12 @@ def sa_cap(Usize=1):
pl2 = 6
pw2 = 11

k1 = polyline([(bw2, bl2), (bw2, -bl2), (-bw2, -bl2), (-bw2, bl2), (bw2, bl2)])
k1 = extrude_poly(outer_poly=k1, height=0.1)
k1 = box(bw2 * 2, bl2 * 2, 0.1)
k1 = translate(k1, (0, 0, 0.05))
k2 = polyline([(pw2, pl2), (pw2, -pl2), (-pw2, -pl2), (-pw2, pl2), (pw2, pl2)])
k2 = extrude_poly(outer_poly=k2, height=0.1)
k2 = box(pw2 * 2, pl2 * 2, 0.1)
k2 = translate(k2, (0, 0, 12.0))
if m > 0:
m1 = polyline([(m, m), (m, -m), (-m, -m), (-m, m), (m, m)])
m1 = extrude_poly(outer_poly=m1, height=0.1)
m1 = box(m * 2, m * 2, 0.1)
m1 = translate(m1, (0, 0, 6.0))
key_cap = hull_from_shapes((k1, k2, m1))
else:
Expand All @@ -398,14 +395,10 @@ def choc_cap(Usize=1):
pt = 1.5
gap = 1.5

k1 = polyline([(bw2, bl2), (bw2, -bl2), (-bw2, -bl2), (-bw2, bl2), (bw2, bl2)])
k1 = extrude_poly(outer_poly=k1, height=0.1)
k1 = translate(k1, (0, 0, 0.05))
k2 = polyline([(bw2, bl2), (bw2, -bl2), (-bw2, -bl2), (-bw2, bl2), (bw2, bl2)])
k2 = extrude_poly(outer_poly=k2, height=0.1)
k2 = translate(k2, (0, 0, 0.05+bt))
k3 = polyline([(pw2, pl2), (pw2, -pl2), (-pw2, -pl2), (-pw2, pl2), (pw2, pl2)])
k3 = extrude_poly(outer_poly=k3, height=0.1)
k_box = box(bw2 * 2, bl2 * 2, 0.1)
k1 = translate(k_box, (0, 0, 0.05))
k2 = translate(k_box, (0, 0, 0.05+bt))
k3 = box(pw2 * 2, pl2 * 2, 0.1)
k3 = translate(k3, (0, 0, 0.05+bt+pt))
key_cap = hull_from_shapes((k1, k2, k3))

Expand Down
28 changes: 3 additions & 25 deletions src/helpers_cadquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

debug_trace = False


def debugprint(info):
if debug_trace:
print(info)
Expand Down Expand Up @@ -88,6 +89,7 @@ def intersect(shape1, shape2):
else:
return shape1


def face_from_points(points):
# debugprint('face_from_points()')
edges = []
Expand Down Expand Up @@ -166,9 +168,6 @@ def triangle_hulls(shapes):
return union(hulls)





def bottom_hull(p, height=0.001):
debugprint("bottom_hull()")
shape = None
Expand Down Expand Up @@ -199,27 +198,6 @@ def bottom_hull(p, height=0.001):
return shape


def polyline(point_list):
return cq.Workplane('XY').polyline(point_list)


# def project_to_plate():
# square = cq.Workplane('XY').rect(1000, 1000)
# for wire in square.wires().objects:
# plane = cq.Workplane('XY').add(cq.Face.makeFromWires(wire))


def extrude_poly(outer_poly, inner_polys=None, height=1): # vector=(0,0,1)):
outer_wires = cq.Wire.assembleEdges(outer_poly.edges().objects)
inner_wires = []
if inner_polys is not None:
for item in inner_polys:
inner_wires.append(cq.Wire.assembleEdges(item.edges().objects))

return cq.Workplane('XY').add(
cq.Solid.extrudeLinear(outerWire=outer_wires, innerWires=inner_wires, vecNormal=cq.Vector(0, 0, height)))


def import_file(fname, convexity=None):
print("IMPORTING FROM {}".format(fname))
return cq.Workplane('XY').add(cq.importers.importShape(
Expand All @@ -236,4 +214,4 @@ def export_file(shape, fname):
def export_dxf(shape, fname):
print("EXPORTING TO {}".format(fname))
cq.exporters.export(w=shape, fname=fname + ".dxf",
exportType='DXF')
exportType='DXF')
21 changes: 4 additions & 17 deletions src/helpers_solid.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

debug_trace = False


def debugprint(info):
if debug_trace:
print(info)


def box(width, height, depth):
return sl.cube([width, height, depth], center=True)

Expand Down Expand Up @@ -85,6 +87,7 @@ def intersect(shape1, shape2):
else:
return shape1


def hull_from_points(points):
return sl.hull()(*points)

Expand All @@ -111,7 +114,6 @@ def triangle_hulls(shapes):
return union(hulls)



def bottom_hull(p, height=0.001):
debugprint("bottom_hull()")
shape = None
Expand All @@ -126,21 +128,6 @@ def bottom_hull(p, height=0.001):
shape = sl.hull()(p, shape, t_shape)
return shape

def polyline(point_list):
return sl.polygon(point_list)


# def project_to_plate():
# square = cq.Workplane('XY').rect(1000, 1000)
# for wire in square.wires().objects:
# plane = cq.Workplane('XY').add(cq.Face.makeFromWires(wire))

def extrude_poly(outer_poly, inner_polys=None, height=1):
if inner_polys is not None:
return sl.linear_extrude(height=height, twist=0, convexity=0, center=True)(outer_poly, *inner_polys)
else:
return sl.linear_extrude(height=height, twist=0, convexity=0, center=True)(outer_poly)


def import_file(fname, convexity=2):
print("IMPORTING FROM {}".format(fname))
Expand All @@ -154,4 +141,4 @@ def export_file(shape, fname):

def export_dxf(shape, fname):
print("NO DXF EXPORT FOR SOLID".format(fname))
pass
pass