Please help me fix my render code!

Attached is a 3d max script I have been working on.

I have created several scene states with 1 layer with lighting and cameras, always visible. And several layers with geometry in them.

I would render for each task, only one visible geometry layer.

I have 4 cameras and want to render each camera.

The frames would be rendered into root \ layername \ _ cameraIndex \ frame.png

If I use the code, with a png, a blank png is exported.
If I use the code, with a bmp, a black image is exported.

I would like to use the settings from the render dialog box but modifying the output path AND for a specific camera.

Thank you!

render.ms1.31 KB