I have some water bottles that I use to store reverse-osmosis purified 
water from vending machines.  One of them I can't use because it lacks a 
cap.  A 2nd one's cap was breaking apart, and so I needed 2 of them.
I'd 'repaired' a 3rd bottle's cap long ago by gluing a broken cap inside 
something slightly larger.  That's kind of a hack in and of itself.  but 
I needed something better.
ObHack:  While trying to come up with a 3D printed bottle cap, I printed 
just 'the disk part' and stopped the print when it began to slide around 
on the printer base.  However, a bit of filing and hot glue made it 
possible to use that plastic disk to fix one of the bottle caps. That's one.
The final part of this story came 4 attempts later, when I had the basic 
design correct, the diameter of the cap itself, and the thickness of the 
threads.
I used OpenSCAD for it.  Here's the file:
https://github.com/bombasticbob/3DObjects/blob/master/water_bottle.scad
Enjoy!  YMMV as there's some inaccuracy in the printed part vs what the 
CAD system says.  it has a 2% 'shrinkage' compensation in it, but that 
may not be exactly right for every printer.  So if you try it and the 
cap is too large/small you can make adjustments.  Getting threads in a 
bottle cap to work is a little tricky with OpenSCAD but this one does it 
quite well.  Fits nice and snug.
3D Printing and OpenSCAD is total hack material.  I'll post more designs 
on that github site as time goes on, no doubt.
-- 
(aka 'Bombastic Bob' in case you wondered)
'Feeling with my fingers, and thinking with my brain' - me
'your story is so touching, but it sounds just like a lie'
"Straighten up and fly right"