def _setTimeCode(timecode): fields = timecode.split(":") if len(fields) == 4: cmds.timeCode(e=1, productionStartHour=int(fields[0]), productionStartMinute=int(fields[1]), productionStartSecond=int(fields[2]), productionStartFrame=int(fields[3]), mayaStartFrame=0)
def getTimecode_from_maya(): ''' get the internal timecode binding from Maya's production mapping .. note:: Maya has a function for modifying the default mapping through the setTimecode ui which binds a given frame to a given timecode. This code compensates for that binding ''' # maya binding data h=cmds.timeCode(q=True, productionStartHour=True) m=cmds.timeCode(q=True, productionStartMinute=True) s=cmds.timeCode(q=True, productionStartSecond=True) f=cmds.timeCode(q=True, productionStartFrame=True) t=cmds.timeCode(q=True, mayaStartFrame=True) #calculate the actual displayed timecode dif= cmds.currentTime(q=True) - t tcf=timecode_to_frame('%s:%s:%s:%s' % (h,m,s,int(f))) #convert back to timecode return frame_to_timecode(tcf+dif)
def getTimeCode(): # temporarely report the mayaStartTime to the productionstartTime startFrame = int(cmds.timeCode(q=1, mayaStartFrame=1)) hourBackup = int(cmds.timeCode(q=1, productionStartHour=1)) minuteBackup = int(cmds.timeCode(q=1, productionStartMinute=1)) secondBackup = int(cmds.timeCode(q=1, productionStartSecond=1)) frameBackup = int(cmds.timeCode(q=1, productionStartFrame=1)) newFrame = frameBackup - startFrame cmds.timeCode(e=1, productionStartHour=hourBackup, productionStartMinute=minuteBackup, productionStartSecond=secondBackup, productionStartFrame=newFrame) # Extract prodution timecode hour = cmds.timeCode(q=1, productionStartHour=1) minute = cmds.timeCode(q=1, productionStartMinute=1) second = cmds.timeCode(q=1, productionStartSecond=1) frame = cmds.timeCode(q=1, productionStartFrame=1) # restore original timecode values cmds.timeCode(e=1, productionStartHour=hourBackup, productionStartMinute=minuteBackup, productionStartSecond=secondBackup, productionStartFrame=frameBackup) timeCodeStr = '%02d:%02d:%02d:%02d' % (hour, minute, second, frame) return timeCodeStr