/// Boilerplate to determine which document to modify ...
function FindDocument(ScriptName)
{
if(Document)
return Document;
else
{
if(Application.Documents.length == 1)
return Application.Documents[0];
else if(Application.Documents.length == 0)
Application.UI.ErrorMessage("You must have an open document to run this script!", ScriptName + ":");
else
Application.UI.ErrorMessage("Not sure which document to use ... try using the desired document's Document Window > Tools > Play Script.", ScriptName + ":");
}
return null;
}
document = FindDocument("rendertest");
if(document)
{
camera = document.Object("Camera");
if(camera)
camera.RenderPreview();
else
Application.UI.ErrorMessage("Couldn't find object named \"Camera\" to preview", "render_test.javascript");