Skip to content

Instantly share code, notes, and snippets.

@gftabor
Last active August 23, 2018 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gftabor/b05032912fcb7e732a97f93a06985066 to your computer and use it in GitHub Desktop.
Save gftabor/b05032912fcb7e732a97f93a06985066 to your computer and use it in GitHub Desktop.
Adding new file from BowlerStudio
//Your code here
double computeGearPitch(double diameterAtCrown,double numberOfTeeth){
return ((diameterAtCrown/2)*((360.0)/numberOfTeeth)*Math.PI/180)
}
double vexGearSize = 19
double totalWidth = vexGearSize * 0.5
double vexPitch = Math.PI*1.5 * 25.4 / 36
println "pitch " + vexPitch
double pitch = vexPitch * 2
double wallThickness = 0.2
double gap = 0.1
double gearInner =totalWidth - 2 * wallThickness
double bevelMaxWidth = gearInner - gap * 2
println "bevel max width " + bevelMaxWidth
int bevelTeeth = (int) (bevelMaxWidth * 25.4 * Math.PI)/(pitch)
println "bevel teeth " + bevelTeeth
// call a script from another library
double bevelThickness = 25.4/2
def bevelGears = ScriptingEngine.gitScriptRun(
"https://github.com/madhephaestus/GearGenerator.git", // git location of the library
"bevelGear.groovy" , // file to load
// Parameters passed to the funcetion
[ bevelTeeth,// Number of teeth gear a
40,// Number of teeth gear b
bevelThickness/2,// thickness of gear A
pitch,// gear pitch in arc length mm
90,// shaft angle, can be from 0 to 100 degrees
0// helical angle, only used for 0 degree bevels
]
)
def outerGear = ScriptingEngine.gitScriptRun(
"https://github.com/madhephaestus/GearGenerator.git", // git location of the library
"bevelGear.groovy" , // file to load
// Parameters passed to the funcetion
[ vexGearSize * 12,// Number of teeth gear a
5,// Number of teeth gear b
bevelThickness,// thickness of gear A
vexPitch,// gear pitch in arc length mm
0,// shaft angle, can be from 0 to 100 degrees
0// helical angle, only used for 0 degree bevels
]
)
//Print parameters returned by the script
println "Bevel gear axle center to center " + bevelGears.get(2)
println "Bevel gear axle Height " + bevelGears.get(3)
println "Bevel angle " + bevelGears.get(4)
println "Bevel tooth face length " + bevelGears.get(5)
println "Gear B computed thickness " + bevelGears.get(6)
// return the CSG parts
double inside = 8 *25.4
double thickness = 0.5 * 25.4
CSG hole = new Cylinder(inside/2,thickness,(int)100).toCSG()
CSG bevelouter = new Cylinder(gearInner*25.4/2 ,thickness,(int)100).toCSG()
CSG bevelWithHole = bevelGears.get(0).difference(hole)
double bevelHeight = bevelWithHole.getMaxZ() - bevelWithHole.getMinZ()
CSG underBevel = new Cylinder(gearInner*25.4/2 ,thickness-bevelHeight,(int)50).toCSG()
CSG bevelSupport = underBevel.difference(hole)
CSG outWithSupport = outerGear.get(0).difference(bevelouter).union(bevelSupport)
CSG gear = outWithSupport.movez(-1*bevelWithHole.getMaxZ()).union(bevelWithHole)
CSG cylin = new Cylinder(totalWidth *25.4 /2 ,thickness,(int)100).toCSG()
CSG bearing = cylin.difference(hole)
CSG moved = bearing.movez(gear.getMinZ() - bearing.getMaxZ())
CSG bottom = moved.union(gear)
double axleSize = 25.4 /4 +0.1
CSG axleHole = new Cube(25.4*2,axleSize,axleSize).toCSG().movez(bevelGears.get(3)).movex(-1*bevelGears.get(2))
CSG withAxle = bevelGears.get(1).difference(axleHole)
return [withAxle]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment