MuesliMix/cad_script.py

51 lines
1.2 KiB
Python

from FreeCAD import Rotation, Base, newDocument
doc = newDocument()
def create_blade(radius_rod, diameter):
# set parameters (in mm)
# central rod
outer_radius = radius_rod
inner_radius = outer_radius / 2
height = diameter
# blades
thickness = 1.5
rod = Part.makeCylinder(outer_radius, height, Base.Vector(0,0,0), Base.Vector(1,0,0))
hole_template = Part.makeCylinder(inner_radius, height+2, Base.Vector(-1,0,0), Base.Vector(1,0,0))
pierced_rod = rod.cut(hole_template)
del hole_template # remove the template
# blades
blade_template = Part.makeCylinder(height/2, thickness, Base.Vector(height/2,0, -thickness/2))
#Part.show(blade_template)
blades1 = blade_template.cut(rod)
blades2 = blades1.copy()
blades2.Placement.Rotation = Rotation(0, 0, 60)
blades3 = blades1.copy()
blades3.Placement.Rotation = Rotation(0, 0, -60)
del blade_template # remove the template
# show all the stuff we created just now
Part.show(pierced_rod)
Part.show(blades1)
Part.show(blades2)
Part.show(blades3)
doc.recompute()
# small dispensers
radius_rod = 4.0
diameter = 34.0
create_blade(radius_rod, diameter)
# big dispensers
#radius_rod = 4.0
#diameter = 94.0
#create_blade(radius_rod, diameter)