Skip to content

Commit

Permalink
fixed examples and madcad functions relying on recent API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jimy-byerley committed Sep 7, 2024
1 parent 1e144a9 commit d89d327
Show file tree
Hide file tree
Showing 20 changed files with 441 additions and 611 deletions.
6 changes: 3 additions & 3 deletions examples/axis-holder.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
# merge the start and end sections of the revolution (because its a 360° revolution)
cone.mergeclose()
# chamfer the lower edge: this is a chamfer over a circular edge
chamfer(cone, cone.frontiers((0,4)), ('depth', 3))
chamfer(cone, cone.frontiers((0,4)), depth=3)



Expand Down Expand Up @@ -86,12 +86,12 @@
# merge outlines of both generated faces
place.mergeclose()
# round the cutting edge to have smooth transition
bevel(
filet(
place,
( place.frontiers(0,3) # this is the frontier line between group 0 and group 3
+ place.frontiers(1,3) # this is the frontier line between group 1 and group 3
+ place.frontiers(2,3) ),
('depth', 2))
depth=2)

# make the screw holes:
# a cylinder (not necessarily closed on its ends as we don't care of that surfaces)
Expand Down
4 changes: 2 additions & 2 deletions examples/bearing.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
vec3(rint, 0, -w),
vec3(rint+e, 0, -w),
]) .segmented() .flip()
bevel(interior, [1, 2], ('radius',c), resolution=('div',1))
filet(interior, [1, 2], radius=c, resolution=('div',1))

exterior = Wire([
vec3(rext-e, 0, -w),
vec3(rext, 0, -w),
vec3(rext, 0, w),
vec3(rext-e, 0, w),
]) .segmented() .flip()
bevel(exterior, [1,2], ('radius',c), resolution=('div',1))
filet(exterior, [1,2], radius=c, resolution=('div',1))


# detailed interior
Expand Down
2 changes: 1 addition & 1 deletion examples/birfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
cage = revolution(wire([rsphere*vec3(cos(t), 0, sin(t)) for t in linrange(-0.75*amax, 0.75*amax, div=10)]))

window = parallelogram(2.3*rball*Y, 2*rball*Z, align=vec3(0.5), fill=False) .transform(rsphere*X)
bevel(window, [0, 1, 2, 3], ('width', rball))
filet(window, [0, 1, 2, 3], width=rball)
cage = thicken(
pierce(cage,
repeat(extrusion(window, rball*X, alignment=0.5), nballs, rotate(2*pi/nballs, Z))),
Expand Down
6 changes: 3 additions & 3 deletions examples/compound-planetary.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,9 @@ def spurgear(step, teeth, height, **kwargs):
in_ext.center + (in_ext.radius + 1.5*dscrew_in)*X,
in_center + (in_ext.radius + 1.5*dscrew_in)*X,
]).segmented().flip()
filet(shell, [12, 11], ('width', 0.5*height))
filet(shell, [10], ('width', 0.5*dscrew_out))
filet(shell, [1], ('width', 0.5*height))
filet(shell, [12, 11], width=0.5*height)
filet(shell, [10], width=0.5*dscrew_out)
filet(shell, [1], width=0.5*height)
shell = intersection(revolution(shell), crown_in_teeth)

# put screws to hold everything
Expand Down
20 changes: 12 additions & 8 deletions examples/differential-asymetric.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from madcad import *
from madcad.gear import *
from madcad.joints import *

# bevelgear with annotations
def sbevelgear(step, z, pitch_cone_angle, **kwargs):
Expand Down Expand Up @@ -29,16 +30,15 @@ def bolt(a, b, dscrew, washera=False, washerb=False):
note_radius(rscrew['part'].group(0)),
]
return Solid(
screw = rscrew.place((Pivot, rscrew['axis'], Axis(a-thickness*dir, -dir))),
nut = rnut.place((Pivot, rnut['top'], Axis(b+thickness*dir, -dir))),
w1 = rwasher.place((Pivot, rwasher['top'], Axis(b, -dir))),
w2 = rwasher.place((Pivot, rwasher['top'], Axis(a, dir))),
screw = rscrew.place((Revolute, rscrew['axis'], Axis(a-thickness*dir*int(washera), -dir))),
nut = rnut.place((Revolute, rnut['top'], Axis(b+thickness*dir*int(washerb), -dir))),
w1 = rwasher.place((Revolute, rwasher['top'], Axis(b, -dir))),
w2 = rwasher.place((Revolute, rwasher['top'], Axis(a, dir))),
)



#settings.primitives['curve_resolution'] = ('rad', 0.105)
settings.primitives['curve_resolution'] = ('rad', 0.19456)
settings.primitives['curve_resolution'] = ('sqradm', 0.5)

transmiter_angle = pi/6
transmiter_z = 8
Expand Down Expand Up @@ -123,7 +123,11 @@ def bolt(a, b, dscrew, washera=False, washerb=False):

interior_space = union(
icosphere(O, space_radius),
cylinder(out_gear['axis'].origin, out_gear['axis'].origin*vec3(1,1,-1), bearing_radius*1.05, fill=False),
cylinder(
out_gear['axis'].origin,
out_gear['axis'].origin*vec3(1,1,-1),
bearing_radius*1.05,
fill=False),
).flip()

interior_shell = union(interior_space, interior_out)
Expand Down Expand Up @@ -157,7 +161,7 @@ def bolt(a, b, dscrew, washera=False, washerb=False):
head = intersection(screw_support, slots)

l = length(transmiter['gear']['axis'].origin) + 2*transmiter_rint
transmiter_back = revolution(2*pi, Axis(O,Z), Wire([
transmiter_back = revolution(Wire([
l*Z,
l*Z + transmiter_rint*1.5*X,
rotate(pi/6, Y) * space_radius*Z,
Expand Down
4 changes: 2 additions & 2 deletions examples/differential-symetric.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ def bolt(a, b, dscrew, washera=False, washerb=False):
note_distance_planes(*transmiter['bearing']['part'].group(2).islands()),
]
transmiter['washer']['annotations'] = [
note_distance_planes(transmiter['washer']['part'].group(1), transmiter['washer']['part'].group(2)),
note_radius(transmiter['washer']['part'].group(0).islands()[1]),
note_distance_planes(transmiter['washer']['part'].group(1), transmiter['washer']['part'].group(0)),
note_radius(transmiter['washer']['part'].group(2).islands()[1]),
]
# generate the maximum possible number of transmiters, so that the total force that can be hold is high
transmiter_amount = ceil(axis_z / (1.5*transmiter_z/pi))
Expand Down
11 changes: 6 additions & 5 deletions examples/double-universal-joint.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from madcad import *
from madcad.joints import *
from itertools import accumulate
settings.primitives['curve_resolution'] = ('rad', 0.1)

Expand Down Expand Up @@ -106,10 +107,10 @@ def bolt(a, b, radius, washera=False, washerb=False):
rscrew = screw(radius*2, distance(a,b) + 3*radius)
rnut = nut(radius*2)
return Solid(
screw = rscrew.place((Pivot, rscrew['axis'], Axis(a-thickness*dir, -dir))),
nut = rnut.place((Pivot, rnut['bottom'], Axis(b+thickness*dir, -dir))),
w1 = rwasher.place((Pivot, rwasher['top'], Axis(b-0.5*thickness*dir, -dir))),
w2 = rwasher.place((Pivot, rwasher['top'], Axis(a+0.5*thickness*dir, dir))),
screw = rscrew.place((Revolute, rscrew['axis'], Axis(a-thickness*dir, -dir))),
nut = rnut.place((Revolute, rnut['top'], Axis(b+thickness*dir, -dir))),
w1 = rwasher.place((Revolute, rwasher['top'], Axis(b, -dir))),
w2 = rwasher.place((Revolute, rwasher['top'], Axis(a, dir))),
)

# central part of the universal joint
Expand All @@ -126,7 +127,7 @@ def moyeu(brext, rext, thickness, brint=None, slot=False):
xint*X - 0.3*brext*X + 1.1*brext*Z
]) .segmented()
profile.qualify('axis', select=1)
chamfer(profile, [1], ('radius', 0.1*brext))
chamfer(profile, [1], radius=0.1*brext)
tip = revolution(profile, Axis(O,X))
tip.finish()

Expand Down
Loading

0 comments on commit d89d327

Please sign in to comment.