Last active
May 20, 2023 03:30
-
-
Save kwahoo2/b7ffd1d7671181e97a18026256afa866 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script creates ABENICS (half of) cross gear in FreeCAD | |
import FreeCAD as App | |
import Part | |
import InvoluteGearFeature | |
doc = App.ActiveDocument | |
mod = 2.0 # gear tooth module | |
monopole_teeth = 12 # number of teeth | |
cross_teeth = monopole_teeth * 2 | |
height = 20 # height of the monopole gear | |
rev_radius = cross_teeth * mod * 3.0 / 4.0 # radius for tool movement during cutting the monopole gear | |
monopole_base = Part.makeCylinder((mod * (monopole_teeth + 2) / 2) , height / 2) | |
tool_inv = doc.getObject('tool_inv') | |
if not tool_inv: | |
tool_inv = InvoluteGearFeature.makeInvoluteGear('tool_inv') | |
tool_inv.NumberOfTeeth = cross_teeth | |
tool_inv.Modules = mod | |
tool_inv.HighPrecision = False # Otherwise boolean will fail | |
doc.recompute() | |
tool_inv.ViewObject.Visibility = False | |
fill_inv = Part.Face(tool_inv.Shape) | |
box_w = (cross_teeth + 3) * mod | |
box_h = (cross_teeth + 3) * mod / 2 | |
common_box = Part.makeBox(box_w, box_h, 2) | |
common_box.translate(App.Vector(0, 0, -1)) | |
half_inv = fill_inv.common(common_box) | |
half_inv_rot = half_inv.copy() | |
half_inv_rot.rotate(App.Vector(0, 0, 0), App.Vector(0, 0, 1), 90) | |
half_inv_rot.rotate(App.Vector(0, 0, 0), App.Vector(0, 1, 0), 180) | |
cross_quarter = half_inv.revolve(App.Vector(0 ,0 ,0), App.Vector(1, 0, 0), 90) | |
cross_quarter_rot = half_inv_rot.revolve(App.Vector(0 ,0 ,0), App.Vector(0, 1, 0), -90) | |
# Part.show(cross_quarter) | |
# Part.show(cross_quarter_rot) | |
common = cross_quarter.common(cross_quarter_rot) | |
mirr = common.mirror(App.Vector(0, 0, 0), App.Vector(0, 0, 1)) | |
fuse = common.fuse(mirr) | |
mirr = fuse.mirror(App.Vector(0, 0, 0), App.Vector(0, 1, 0)) | |
half_gear = fuse.fuse(mirr) | |
half_gear_refined = half_gear.removeSplitter() # Refine | |
half_gear_obj = Part.show(half_gear_refined) | |
half_gear_obj.Label = 'Cross gear (half)' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script creates ABENICS monopole gear in FreeCAD | |
import FreeCAD as App | |
import Part | |
import InvoluteGearFeature | |
doc = App.ActiveDocument | |
step = 5 # angle step size for tool rotation, setting low value increases computation time a lot | |
mod = 2.0 # gear tooth module | |
monopole_teeth = 12 # number of teeth | |
cross_teeth = monopole_teeth * 2 | |
height = 20 # height of the monopole gear | |
base_corr = 0.8 # increases base shape diameter | |
use_FCGears = False # requires https://github.com/looooo/freecad.gears addon, set True if the addon is installed | |
backlash = 0.3 # only available if use_FCGears set True | |
rev_radius = cross_teeth * mod * 3.0 / 4.0 # radius for tool movement during cutting the monopole gear | |
monopole_base = Part.makeCylinder((mod * (monopole_teeth + 2 + base_corr) / 2) , height / 2) | |
box_w = (cross_teeth + 3) * mod | |
box_h = (cross_teeth + 3) * mod / 2 | |
if use_FCGears: | |
tool_gear = doc.getObject('tool_gear') | |
if not tool_gear: | |
import freecad.gears.commands | |
tool_gear = freecad.gears.commands.CreateInvoluteGear.create() | |
tool_gear.teeth = cross_teeth | |
tool_gear.module = mod | |
tool_gear.backlash = backlash | |
tool_gear.reversed_backlash = True | |
doc.recompute() | |
common_plane = Part.makePlane(box_w, box_h) | |
common_plane.translate(App.Vector(-box_w / 2, -box_h, 0)) | |
tool_gear.Placement.translate(App.Vector(0, 0, -1)) | |
half_inv = tool_gear.Shape.common(common_plane) | |
tool_gear.ViewObject.Visibility = False | |
FreeCADGui.updateGui() | |
if not use_FCGears: # workaround for strange if/else sytax error | |
tool_inv = doc.getObject('tool_inv') | |
if not tool_inv: | |
tool_inv = InvoluteGearFeature.makeInvoluteGear('tool_inv') | |
tool_inv.NumberOfTeeth = cross_teeth | |
tool_inv.Modules = mod | |
doc.recompute() | |
tool_inv.ViewObject.Visibility = False | |
fill_inv = Part.Face(tool_inv.Shape) | |
cut_box = Part.makeBox(box_w, box_h, 2) | |
cut_box.translate(App.Vector(-box_w / 2, 0, -1)) | |
half_inv = fill_inv.cut(cut_box) | |
tool = half_inv.revolve(App.Vector(0, 0, 0), App.Vector(1, 0, 0), 360) | |
monopole_obj = Part.show(monopole_base) | |
monopole_obj.Label = 'Monopole Gear' | |
angle = 0 | |
while angle < 360: | |
tool.translate(App.Vector(rev_radius, 0 , 0)) | |
tool.rotate(App.Vector(0, 0, 0),App.Vector(0, 0, 1), angle) | |
tool.rotate(tool.Placement.Base,App.Vector(0, 0, 1), 0.5 * angle) | |
base_shape = monopole_obj.Shape | |
base_shape = base_shape.cut(tool) | |
monopole_obj.Shape = base_shape | |
doc.recompute() | |
FreeCADGui.updateGui() | |
angle = angle + step | |
tool.Placement = App.Placement(App.Vector(0, 0, 0),App.Rotation(App.Vector(0, 0, 1), 0)) | |
monopole_mirr = base_shape.mirror(App.Vector(0, 0, 0), App.Vector(0, 0, 1)) | |
fused = monopole_obj.Shape | |
fused = fused.fuse(monopole_mirr) | |
monopole_obj.Shape = fused |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment