This is an improved version of timschmidt's parametric shaft collar at http://www.thingiverse.com/thing:2454.
In my original version, a tolerance parameter was added that can be used to improve the final size of the holes for the shaft, the clamping screw, and the trapped nut. The amount of material to be placed in front of the trapped nut was a new parameter. Finally, a parameter is provided for specifying the number of facets to be used.
Rev A is mostly a refinement in how openSCAD is used, although improvements in the shaft collar result include chamfering of the shaft bore hole and shaping of the bottom of the nut slot to match a hexagon nut. The polyhole function from the MCAD library is now used for improved sizing of round holes. Instead of a single tolerance factor being applied to all dimensions, each parameter can now be individually adjusted. A table of standard dimensions for typical screw and nut hardware has been added as comments in the openSCAD file.
Both the original and Rev A STL files are set up for an 8mm or 5/16 diameter shaft and an M3 clamping screw and standard M3 nut.
Open the SCAD file in openSCAD, edit the parameters at the top of the file for your application, render and export a new STL version.
For the clamp to be somewhat flexible, keep the number of solid top and bottom layers to two, and slice with no more than 20% or 25% infill. The overhanging arc over the notch for the screw head may lead to some drooping during printing. Add some support in slicing to prevent it if desired.