This is a Fusion 360 file which will generate mounting rings of custom sizes. You can change the size parameter and everything scales correctly. (I have included ready made 30mm and 20.5mm diameter stl files.)
Two M3 screws, 10 or 12mm, are required to hold the two halves together, and two more are needed to mount it to the rail grip, (also 10 or 12mm). I recommend using my quick release Picatinny rail mount, which is shown in the photos:
You can also use my customizable Picatinny rail:
There are four parameters in the file:
Diameter - set to the diameter of what you grip
Length - the total length of the ring, you may need to adjust the holes if you change this
Standoff - raises the ring off the rail, adjust to suit your needs
Gap - sets the gap between the top and the bottom half when tightened up. Don't set this to zero.
When you change the file it produces three styles; standard, chamfered, and filleted. (To save each variant in one go, right click on the component -> save as stl, and set "structure" to one file per body.)
Prints without supports, use 3 or more perimeters.
For safety reasons, I don't recommend using this on a real firearm.