Custom HUD with framerate


#1

I wish to implement particular data into playblasts.

import os
import pymel.core as pm

user = os.getenv('USERNAME')
def data():
    reel = 'REEL_01'
    seq = '370'
    shot = '010'
    frames = '112'
    frame = pm.currentTime( query=True )
    out = '{0} E{1}_S{2}  << {3}  >> ( {4} ) by: {5}'.format(reel, seq, shot, frame, frames, user)
    return out
    
hud = pm.headsUpDisplay( 'HUD', section = 6, block = 1, blockSize = 'medium', label = 'SHOT DATA:', labelFontSize='large', command = data, event='idle')

The problem is that current frame info ( pm.currentTime( query=True ) ) updates only when you scroll timeline in Maya, but not during making playblast. I know there predefined HUD “current frame” but i wish to sort information in custom way and have grater control over it.


#2

Can you change your event from idle to timeChanged?


#3

I didn`t get what you meant, sorry.


#4

Changing:


hud = pm.headsUpDisplay( 'HUD', section = 6, block = 1, blockSize = 'medium', label = 'SHOT DATA:', labelFontSize='large', command = data, event='idle')

…over to:


hud = pm.headsUpDisplay( 'HUD', section = 6, block = 1, blockSize = 'medium', label = 'SHOT DATA:', labelFontSize='large', command = data, event='timeChanged')

…on testing though, it updates in the viewport but not playBlast which is annoying!

Maybe have a look at what event the native frame rate HUD uses and copy that?

On further digging I think removing the event altogether and replacing with attachToRefresh=True is the way to go:


import os
import pymel.core as pm

user = os.getenv('USERNAME')
def data():
    reel = 'REEL_01'
    seq = '370'
    shot = '010'
    frames = '112'
    frame = pm.currentTime( query=True )
    out = '{0} E{1}_S{2}  << {3}  >> ( {4} ) by: {5}'.format(reel, seq, shot, frame, frames, user)
    return out
    
hud = pm.headsUpDisplay ( 'HUD', section = 6, block = 1, blockSize = 'medium', label = 'SHOT DATA:', labelFontSize='large', command = data, attachToRefresh = True)



#5

Thans, Faux, thats works! Happy New Year! :slight_smile:


#6

And now i wish to know, how to check if HUD exists (to delete it)…
Now i just delete HUD by position before create it (headsUpDisplay( rp = ( 6 , 1 ) ))


#7

The headsUpDisplay command returns you an ID when you create a new one. You can use -rid/removeID to remove using this ID number. Or if you assigned the headsUpDisplay a unique name, you can use that name for removal with the -rem/remove flag.

string $hudName = "myCustomHUDName";
string $hudID = `headsUpDisplay ... $hudName`; // fill in the flags etc.

// You can remove using the $hudName
headsUpDisplay -remove $hudName;

// Or, you can remove using the $hudID
headsUpDisplay -rid $hudID;