Maya Playblast with ImagePlane - Python


#1

Hi everyone,

I’m creating a script that setup automatically a scene and after it makes the playblast.
For the scene I create a camera, load a sound and place a Image plane with a video. So my problem is that the GUI from maya only updates after the script ends making my “video” Image Plane to stand still the hole playblast time. After the script ends, then the image plane updates his values and sets the Image Number to the current frame.
I really think that this is my problem.
Is there any way to force the GUI refresh?

from maya import cmds
import csv

cmds.workspace( directory='C:/Testing/')     

path='C:/Testing/'

csv_path= path + 'Playblast.csv'                            

#open csv file
with open(csv_path, 'rb') as f:

    #values table location values from file
    reader = csv.reader(f, delimiter=',')
    col_maya = [0]
    col_mov = [1]
    col_snd = [2]
    col_time = [3]
    col_plb = [4]
    
    for row in reader:

        #getting values
        maya_path = list(row[i] for i in col_maya)
        mov_path = list(row[i] for i in col_mov)
        snd_path = list(row[i] for i in col_snd)
        time_path = list(row[i] for i in col_time)      
        plb_path = list(row[i] for i in col_plb)

        #clean values "noise"
        var_mov = ', '.join(mov_path)
        var_snd = ', '.join(snd_path)
        var_time = ', '.join(time_path)
        var_plb = ', '.join(plb_path)

        #open maya file
        cmds.file(new=True, force=True) 
        cmds.file(maya_path, open=True)

        #set sound
        cmds.sound(file=var_snd )

        #set camera
        cameraName = cmds.camera(name="PBcam",horizontalFilmAperture=1.28 , verticalFilmAperture=0.72 , focalLength=80 , fStop=5.6 , focusDistance=5 , shutterAngle=144 , centerOfInterest=165.308)
        cmds.move(0,160,200,cameraName)
        cmds.lookThru(cameraName)

        #set image plane
        myImagePlane = cmds.imagePlane( name="PBvideo", qt=True, lookThrough="PBcam1", fileName=var_mov)

        cmds.setAttr('PBvideoShape2.useFrameExtension',1)        
        cmds.setAttr('PBvideoShape2.type',2)        
        cmds.move(-26,160,0, myImagePlane)
        cmds.scale(2,2,0,myImagePlane) 
       
        #set playback time
        cmds.playbackOptions( minTime='0', maxTime=var_time )

        #playblast
        cmds.playblast( format = "qt" , cc = 1 ,sound = var_plb[3:], filename = path + var_plb)

        #save
        cmds.file( save=True, type='mayaAscii' )

#2

I wrote a playblast script but I have never used .mov or any of the container formats for imagePlanes or output. I always use file sequences which work fine.

I’m assuming you have tried the playblast part by launching it manually within maya (ie not via a script). If that works, then I’m not sure.

David


#3


imagenumber

I’ve tried to use image sequences but my problem remains the same. The attribute “Image Number” just turns pink after the script ends. So it don’t update the image sequence while in playblast.


#4

Hi friend
try to use image sq as your image plane

see below mel code

// create a new image plane
string $imagePlaneName = createNode imagePlane -n "postPlaybalst";
// assign the imageplane to the camera
cameraImagePlaneUpdate “myCamera” $imagePlaneName;
setAttr ($imagePlaneName+".type") 2;
// the path to the image File sequence
string $myImageFileSequence = “C:/Users/admin/Desktop/test/ImagePlaneTest/New folder/PB 01.png”;
// assign images to the imagePlane
setAttr ( $imagePlaneName + “.imageName” ) -type “string” $myImageFileSequence;
// makes the imagesPlane use a image sequence
setAttr ( $imagePlaneName + “.useFrameExtension” ) 1;
setAttr ( $imagePlaneName + “.alphaGain” ) 0.5;

playblast -format avi -sequenceTime 0 -clearCache 1 -viewer 1 -showOrnaments 1 -fp 4 -percent 50 -compression “none” -quality 70;
//playblast -format avi -sequenceTime 0 -clearCache 1 -viewer 1 -showOrnaments 1 -fp 4 -percent 50 -compression “none” -quality 70;
play -state off;
select -r $imagePlaneName;
doDelete;