ChainringGen / making a chainring with open source software

ChainringGen is an OpenSCAD script I wrote that can generate a bike chainring with any specifications you like.

You can download ChainringGen here:

You can control parameters like bolt-circle-diameter (BCD), number of bolt holes, number of teeth and other stuff.

I primarily created ChainringGen because I thought designing / milling my own 110 BCD 39 tooth chainring would be the most practical and economic way to obtain one.

I also wanted to explore ways I could get from an OpenSCAD design to an object created on my CNC mill.  It’s a bit trickier than just exporting an STL file.

The video above includes instructions on how to use ChainringGen in conjunction with other open-source tools to actually make a chainring out of 7075 aluminum using an inexpensive CNC mill.

Stuff I used:

Zen Toolworks – mill

OpenSCAD – design

MakerCAM – toolpathing

Universal Gcode Sender – Gcode sender!

GRBL – CNC controller

MakerCam is both quite useful – but also limited.  Instead of dealing with 3d objects directly – it converts 2d paths / areas into (3d) milling operations that you define manually.  It also likes niceties like being able to save your work.

I’ll say that compared to 3d printing – the open-source toolpathing options for CNC milling seem immature.  I couldn’t find any “full 3d” options that were stable / usable.

If you’re getting into milling – I’d definitely suggest checking out these resources in addition:

Autodesk Fusion 360 – free for students / hobbyists (commercial) CAD software with built-in mill toolpathing

TinyG – Inexpensive, arm-based CNC controller with built-in motor drivers

ChillPeppr – Web-based CNC control software with lots of cool stuff

PyCAM – Open source 3-axis toolpath generator (interesting – but seems abandoned / buggy)


Be sure to check out my other bike-related projects:

3d printed friction shifter

3d printed SRAM TT500 friction conversion




Related Posts

9 thoughts on “ChainringGen / making a chainring with open source software

  1. I tried to use the script but it tells me that there is a parser error in line 100?

    Please can you advise?

  2. Interesting chainring project. I want to build a 110 BCD to 130 BCD adapter to make a particular crank compatible with a Gates Carbon Drive belt ring. Ever see anything like that?

    1. I haven’t – but I’ve thought about making a 3d printed crank out of nylon – or something else tough… ended up not pursuing – at least partially out of concerns about tensioning.

  3. Thank you for providing this. I’m going to have a go a making a 28T 94mm BCD 5-bolt chainring to get the right gearing for my 1×9 mountain bike. I can’t get anything locally in New Zealand for my bike in that size. How is your chainring after a few months use? Have you ever considered making oval or non-round chainrings?

    1. Haven’t tried making any oval chainrings myself – but I recall a while ago another user mentioning they modified the script to do so with some success.

      Chainring works fine – but it’s not on my make bike – so maybe only 100 miles or so on it. 7075 aluminum is commonly used for chainring – so no reason to think it’ll have wear issues.


  4. I have been making my own chainrings for a while now – ghetto style – using Giles Puckett’s spacely sprockets widget:
    I like your script for OpenSCad but I want to be able to make elliptical chainrings. How difficult would it be to modify your script to include a simple eccentricity parameter? I have been looking through the options for generating oval or ellipses but they all rely on scaling. The precision needed for a chainring means scaling is not going to work. Need to be able to array the tooth profile exactly about the two radii at each end of the ellipse. But this is beyond me to script.

    Otherwise, luv your work!

  5. Really interested in what you’ve done here. I’m looking to design a 68t chainring with narrow wide teeth to stop the chain coming off. Does you tool allow for this? Any tips?


    1. The tool unfortunately cannot produce a narrow-wide chainring. But – I suspect it could with a little work. Have my hands full with other stuff for now – but if you give it a go – let me know how it works!


Leave a Reply

Your email address will not be published. Required fields are marked *