Inspired by kriegs' 12mm version, written up for the Customizer. I tend to use 16mm dice but maybe you need 24mm, or pixie dice.
Update 2: Tweaked the script to separate the concept of die size from the fit tolerance.
Update 3: Recoded entirely using the new functionality of OpenScad (basically, the offset() function) to improve reliability. Also, added rounded corners because offset() makes that easy.