Script to link Optimize modifier parameter to distance of object from camera

Please help me write a script to apply this to multiple objects.

I read about this in one of Pete Draper's tutorials wich are unfortunately no longer available on 3dpalace server.

It is a way to link Optimize modifier parameter to distance of the object from camera and I want to apply it to many objects.

ocmtime