Maya: Camera Image Plane
Setting a video file to a new camera
import maya.cmds as mc;
# Creating a new default camera
cam= mc.camera();
# Transform node of the camera
cam_transform= cam[0];
# Camera shape node
cam_shape= cam[1];
# Camera shape imagePlane attribute
image_plane_attr= cam_shape+".imagePlane";
# A video file
my_video_file= "my_video_file.avi";
# Applying a video file to camera's image plane attribute
image_plane_nodes= mc.imagePlane(image_plane_attr,fn=my_video_file);
# Transform node of image plane
image_plane_transform= image_plane_nodes[0];
# Image plan shape node
image_plane_shape= image_plane_nodes[1];
# Setting image plane type attribute to "movie"
mc.setAttr(image_plane_shape+".type",2);
To my knowledge, it ends up with disabled Image Number. (No expression is generated)
So, I studied through echoed all commands and decided to use MEL command.
-
import maya.cmds as mc;
# Create an imagePlane node using createNode command
image_plane_node= mc.createNode("imagePlane");
# Setting image plane type attribute to "movie"
mc.setAttr(image_plane_node+".type",2);
import maya.mel as mm;
# MEL command string
mel_command_string= "AEimagePlaneBrowser \"AEassignImageCB "+image_plane_node+".type "+image_plane_node+".imageName\" "+image_plane_node;
# Execute the MEL command. A window to select a video file will be displayed
mm.eval(mel_command_string);
These still won't work properly.
-
import maya.cmds as mc;
# Creating a new default camera
cam= mc.camera();
# Transform node of the camera
cam_transform= cam[0];
# Camera shape node
cam_shape= cam[1];
import maya.mel as mm;
# Creating image plane node linked to the camera
mel_command_string2= "AEcameraImagePlaneCommand "+cam_shape+".imagePlane "+cam_shape+".horizontalFilmAperture "+cam_shape+".verticalFilmAperture";
mm.eval(mel_command_string2);
# Setting image plane type attribute to "movie"
mc.setAttr(mc.ls(sl=1)[0]+".type",2);
mel_command_string3= "AEimagePlaneBrowser \"AEassignImageCB "+image_plane_node+".type "+image_plane_node+".imageName\" "+image_plane_node;
# Execute the MEL command. A window to select a video file will be displayed
mm.eval(mel_command_string3);
# Setting image plane type attribute to "movie"
mc.setAttr(image_plane_shape+".type",2);
Finally, created an imagePlane node linked to a camera with an expression.


Comments
Post a Comment