I’m using cmds.vrend to save out vrscenes from maya, but it seems to ignore the camera I’m feeding in the parameters, and uses instead the active camera in maya.
Here is my code :
cmds.vrend(camera=renderCamera)
I tried using the camera shape or the transform, but it keeps on ignoring it.
It seems that the camera parameter expects a string value, not an object.
I’ve tried passing the name/dag path of the camera and it seems to work as expected.
I just tried using the mel command instead of the python command :
vrendCommand = ‘vrend -camera %s %s’ % (renderCamera, ‘masterLayer’)
mel.eval (vrendCommand)
I think the -camera flag for the MEL command is passed differently to the MEL function compared to camera=<string> in Python and the command probably does not recognize it.
import maya.cmds as cmds
import maya.mel as mel
cameras = cmds.ls(type='camera')
renderlayers = cmds.ls(type='renderLayer')
for renderlayer in renderlayers :
cmds.editRenderLayerGlobals(currentRenderLayer=renderlayer) # Actually step to the current render layer in scene
for camera in cameras:
mel.eval('vrend -camera ' + camera + ' -layer ' + renderlayer + ' ;') # MEL code for exporting of the .vrscene file
You probably want to also check that the layers and cameras are actually renderable. The code above will just give you everything. Also, this code returns the camera shape. This works, but for nicer presentation you may want to grab the parent with cmds.listRelatives(cmds.ls(type=‘camera’), parent=True) so that you get persp rather than perspShape.