Pre Render Mel / Post Render Mel in Maya
Here's #02 of my tutorial series of handy Maya Tips. Like Tutorial #01 this isn't known by a lot of people, even though it has been in Maya for years!
I'm going to be creating an unbelievably simple scene here to show you what it does, but it will do exactly the same function on larger more complicated scenes, as long as you get the mel commands right!
So if you want to follow along with my scene, start off by creating a cube, and a cone. (The names of these are set to default 'pCube1' & 'pCone1' respectively.
From here, make a note of the names if you do rename them as these will be needed in the mel script we will create.
Open the Script Editor and make a new MEL tab.
Here's a brief explanation of both functions!
Pre Render Mel:
This is a mel script that maya runs when you hit the render button. It process's the script you enter into this tab BEFORE the scene is sent to render.
Post Render Mel:
This is a mel script that maya runs once the render has finished. (Usually you just put the complete opposite to the 'Pre Render Mel' tab so that once the rneder is finished, your scene is left unchanged)
For our little scene we are using the cube and cone as an example as if the cone is a HIGH resolution object that is identical to the cube (LOW resoultion object) but allows the maya scene to stay light and useable.
For our example, in the script editor we will write:
Copy and Paste this into the Pre Render Mel Tab as shown below:
Now we write the exact opposite into the Post Render Mel - For our scene just copy and paste into the Post Render Mel and swap the Names around and we're done!
Now, when we hit render you'll see that the cube - although showing up in the viewport - does not render and is hidden!
Instead the Cone is un-hidden and renders in the cubes place!
Again, to re-iterate, use this in larger scenes to reap the reward. For a small setup time it can really help speed up scene rendering / useability!
I hope this tutorial has helped!