Esempio n. 1
0
def JiggleTimeline():
    currentTime = FBPlayerControl().GetEditCurrentTime()
    FBPlayerControl().GotoStart()
    FBSystem().Scene.Evaluate()
    FBPlayerControl().GotoEnd()
    FBSystem().Scene.Evaluate()
    FBPlayerControl().Goto(currentTime)
    FBSystem().Scene.Evaluate()
Esempio n. 2
0
    def set_frame_range(self, engine, in_frame, out_frame):

        if engine == "tk-maya":
            import pymel.core as pm
            
            # set frame ranges for plackback
            pm.playbackOptions(minTime=in_frame, 
                               maxTime=out_frame,
                               animationStartTime=in_frame,
                               animationEndTime=out_frame)
           
            # set frame ranges for rendering
            defaultRenderGlobals=pm.PyNode('defaultRenderGlobals')
            defaultRenderGlobals.startFrame.set(in_frame)
            defaultRenderGlobals.endFrame.set(out_frame)
           
        elif engine == "tk-nuke":
            import nuke

            # unlock
            locked = nuke.root()["lock_range"].value()
            if locked:
                nuke.root()["lock_range"].setValue(False)
            # set values
            nuke.root()["first_frame"].setValue(in_frame)
            nuke.root()["last_frame"].setValue(out_frame)
            # and lock again
            if locked:
                nuke.root()["lock_range"].setValue(True)

        elif engine == "tk-motionbuilder":
            from pyfbsdk import FBPlayerControl, FBTime

            lPlayer = FBPlayerControl()
            lPlayer.LoopStart = FBTime(0, 0, 0, in_frame)
            lPlayer.LoopStop = FBTime(0, 0, 0, out_frame)

        elif engine == "tk-softimage":
            import win32com
            Application = win32com.client.Dispatch('XSI.Application')

            Application.SetValue("PlayControl.In", in_frame)
            Application.SetValue("PlayControl.Out", out_frame)

        elif engine == "tk-houdini":
            import hou
            hou.playbar.setPlaybackRange(in_frame, out_frame)

        else:
            raise tank.TankError("Don't know how to set current frame range for engine %s!" % engine)
Esempio n. 3
0
    def set_frame_range(self, in_frame=None, out_frame=None, **kwargs):
        """
        set_frame_range will set the frame range using `in_frame` and `out_frame`

        :param int in_frame: in_frame for the current context
            (e.g. the current shot, current asset etc)

        :param int out_frame: out_frame for the current context
            (e.g. the current shot, current asset etc)

        """

        lPlayer = FBPlayerControl()
        lPlayer.LoopStart = FBTime(0, 0, 0, in_frame)
        lPlayer.LoopStop = FBTime(0, 0, 0, out_frame)
Esempio n. 4
0
    def get_frame_range(self, **kwargs):
        """
        get_frame_range will return a tuple of (in_frame, out_frame)

        :returns: Returns the frame range in the form (in_frame, out_frame)
        :rtype: tuple[int, int]
        """
        lPlayer = FBPlayerControl()
        current_in = lPlayer.LoopStart.GetFrame()
        current_out = lPlayer.LoopStop.GetFrame()
        return (current_in, current_out)
    def get_editorial_data(self, **kwargs):
        """
        get_editorial_data will return a tuple of (in_frame, out_frame, frame_range)

        :returns: Returns the frame data in the form (in_frame, out_frame, frame_range)
        :rtype: tuple[int, int, float]
        """
        lPlayer = FBPlayerControl()
        current_in = lPlayer.LoopStart.GetFrame()
        current_out = lPlayer.LoopStop.GetFrame()
        current_fps = None  # TODO: get frame rate for motionbuilder
        return (current_in, current_out, current_fps)
    def execute(self, operation, in_frame=None, out_frame=None, **kwargs):
        """
        Main hook entry point
        
        :operation: String
                    Frame operation to perform
        
        :in_frame: int
                    in_frame for the current context (e.g. the current shot, 
                                                      current asset etc)
                    
        :out_frame: int
                    out_frame for the current context (e.g. the current shot, 
                                                      current asset etc)
                    
        :returns:   Depends on operation:
                    'set_frame_range' - Returns if the operation was succesfull
                    'get_frame_range' - Returns the frame range in the form (in_frame, out_frame)
        """

        if operation == "get_frame_range":
            lPlayer = FBPlayerControl()
            current_in = lPlayer.LoopStart.GetFrame()
            current_out = lPlayer.LoopStop.GetFrame()
            return (current_in, current_out)
        elif operation == "set_frame_range":
            lPlayer = FBPlayerControl()
            lPlayer.LoopStart = FBTime(0, 0, 0, in_frame)
            lPlayer.LoopStop = FBTime(0, 0, 0, out_frame)
            return True
    def set_editorial_data(self,
                           in_frame=None,
                           out_frame=None,
                           frame_rate=None,
                           **kwargs):
        """
        set_editorial_data will set the frame range using `in_frame` and `out_frame`
        and the frame rate using `frame_rate`

        :param int in_frame: in_frame for the current context
            (e.g. the current shot, current asset etc)

        :param int out_frame: out_frame for the current context
            (e.g. the current shot, current asset etc)

        :param float frame_rate: frame_range for the current context
            (e.g. the current shot, current asset, or current project)

        """

        lPlayer = FBPlayerControl()
        lPlayer.LoopStart = FBTime(0, 0, 0, in_frame)
        lPlayer.LoopStop = FBTime(0, 0, 0, out_frame)
def get_animation(take, items):
    SYSTEM.CurrentTake = take
    SCENE.Evaluate()
    player = FBPlayerControl()

    timespan = take.LocalTimeSpan
    scene_start_frame = timespan.GetStart().GetFrame(True)
    scene_end_frame = timespan.GetStop().GetFrame(True)
    frame = scene_start_frame
    player.Goto(FBTime(0, 0, 0, frame))

    PROGRESS.frames = scene_end_frame

    snapshots = []

    while True:
        SCENE.Evaluate()
        snapshots.append(snapshot(items))
        if frame >= scene_end_frame:
            break
        player.StepForward()
        frame = frame + 1
        PROGRESS.next_frame()
    return snapshots
Esempio n. 9
0
    def get_current_frame_range(self, engine):

        if engine == "tk-maya":
            import pymel.core as pm
            import maya.cmds as cmds
            current_in = cmds.playbackOptions(query=True, minTime=True)
            current_out = cmds.playbackOptions(query=True, maxTime=True)

        elif engine == "tk-nuke":
            import nuke
            current_in = int(nuke.root()["first_frame"].value())
            current_out = int(nuke.root()["last_frame"].value())

        elif engine == "tk-motionbuilder":
            from pyfbsdk import FBPlayerControl, FBTime

            lPlayer = FBPlayerControl()
            current_in = lPlayer.LoopStart.GetFrame()
            current_out = lPlayer.LoopStop.GetFrame()

        elif engine == "tk-softimage":
            import win32com
            xsi = win32com.client.Dispatch('XSI.Application')

            current_in = xsi.GetValue("PlayControl.In")
            current_out = xsi.GetValue("PlayControl.Out")

        elif engine == "tk-houdini":
            import hou
            current_in, current_out = hou.playbar.playbackRange()

        elif engine == "tk-3dsmax":
            from Py3dsMax import mxs
            current_in = mxs.animationRange.start
            current_out = mxs.animationRange.end
        elif engine == "tk-3dsmaxplus":
            import MaxPlus
            ticks = MaxPlus.Core.EvalMAXScript("ticksperframe").GetInt()
            current_in = MaxPlus.Animation.GetAnimRange().Start() / ticks
            current_out = MaxPlus.Animation.GetAnimRange().End() / ticks

        else:
            raise tank.TankError(
                "Don't know how to get current frame range for engine %s!" %
                engine)

        return (current_in, current_out)
Esempio n. 10
0
    def set_frame_range(self, engine, in_frame, out_frame):

        if engine == "tk-maya":
            import pymel.core as pm

            # set frame ranges for plackback
            pm.playbackOptions(minTime=in_frame,
                               maxTime=out_frame,
                               animationStartTime=in_frame,
                               animationEndTime=out_frame)

            # set frame ranges for rendering
            defaultRenderGlobals = pm.PyNode('defaultRenderGlobals')
            defaultRenderGlobals.startFrame.set(in_frame)
            defaultRenderGlobals.endFrame.set(out_frame)

        elif engine == "tk-nuke":
            import nuke

            # unlock
            locked = nuke.root()["lock_range"].value()
            if locked:
                nuke.root()["lock_range"].setValue(False)
            # set values
            nuke.root()["first_frame"].setValue(in_frame)
            nuke.root()["last_frame"].setValue(out_frame)
            # and lock again
            if locked:
                nuke.root()["lock_range"].setValue(True)

        elif engine == "tk-motionbuilder":
            from pyfbsdk import FBPlayerControl, FBTime

            lPlayer = FBPlayerControl()
            lPlayer.LoopStart = FBTime(0, 0, 0, in_frame)
            lPlayer.LoopStop = FBTime(0, 0, 0, out_frame)

        elif engine == "tk-softimage":
            import win32com
            Application = win32com.client.Dispatch('XSI.Application')

            # set playback control
            Application.SetValue("PlayControl.In", in_frame)
            Application.SetValue("PlayControl.Out", out_frame)
            Application.SetValue("PlayControl.GlobalIn", in_frame)
            Application.SetValue("PlayControl.GlobalOut", out_frame)

            # set frame ranges for rendering
            Application.SetValue("Passes.RenderOptions.FrameStart", in_frame)
            Application.SetValue("Passes.RenderOptions.FrameEnd", out_frame)

        elif engine == "tk-houdini":
            import hou
            # We have to use hscript until SideFX gets around to implementing hou.setGlobalFrameRange()
            hou.hscript("tset `((%s-1)/$FPS)` `(%s/$FPS)`" %
                        (in_frame, out_frame))
            hou.playbar.setPlaybackRange(in_frame, out_frame)

        elif engine == "tk-3dsmax":
            from Py3dsMax import mxs
            mxs.animationRange = mxs.interval(in_frame, out_frame)

        else:
            raise tank.TankError(
                "Don't know how to set current frame range for engine %s!" %
                engine)
Esempio n. 11
0
    def set_frame_range(self, engine, in_frame, out_frame):

        if engine == "tk-maya":
            import pymel.core as pm
            
            # set frame ranges for plackback
            pm.playbackOptions(minTime=in_frame, 
                               maxTime=out_frame,
                               animationStartTime=in_frame,
                               animationEndTime=out_frame)
            
            # set frame ranges for rendering
            defaultRenderGlobals=pm.PyNode('defaultRenderGlobals')
            defaultRenderGlobals.startFrame.set(in_frame)
            defaultRenderGlobals.endFrame.set(out_frame)
           
        elif engine == "tk-nuke":
            import nuke

            # unlock
            locked = nuke.root()["lock_range"].value()
            if locked:
                nuke.root()["lock_range"].setValue(False)
            # set values
            nuke.root()["first_frame"].setValue(in_frame)
            nuke.root()["last_frame"].setValue(out_frame)
            # and lock again
            if locked:
                nuke.root()["lock_range"].setValue(True)

        elif engine == "tk-motionbuilder":
            from pyfbsdk import FBPlayerControl, FBTime

            lPlayer = FBPlayerControl()
            lPlayer.LoopStart = FBTime(0, 0, 0, in_frame)
            lPlayer.LoopStop = FBTime(0, 0, 0, out_frame)

        elif engine == "tk-softimage":
            import win32com
            Application = win32com.client.Dispatch('XSI.Application')
            
            # set playback control
            Application.SetValue("PlayControl.In", in_frame)
            Application.SetValue("PlayControl.Out", out_frame)
            Application.SetValue("PlayControl.GlobalIn", in_frame)
            Application.SetValue("PlayControl.GlobalOut", out_frame)       
            
            # set frame ranges for rendering
            Application.SetValue("Passes.RenderOptions.FrameStart", in_frame)
            Application.SetValue("Passes.RenderOptions.FrameEnd", out_frame)
            

        elif engine == "tk-houdini":
            import hou
            # We have to use hscript until SideFX gets around to implementing hou.setGlobalFrameRange()
            hou.hscript("tset `((%s-1)/$FPS)` `(%s/$FPS)`" % (in_frame, out_frame))            
            hou.playbar.setPlaybackRange(in_frame, out_frame)

        elif engine == "tk-3dsmax":
            from Py3dsMax import mxs
            mxs.animationRange = mxs.interval(in_frame, out_frame)
        elif engine == "tk-3dsmaxplus":
            import MaxPlus 
            ticks = MaxPlus.Core.EvalMAXScript("ticksperframe").GetInt()
            range = MaxPlus.Interval(in_frame * ticks, out_frame * ticks)
            MaxPlus.Animation.SetRange(range)
        
        else:
            raise tank.TankError("Don't know how to set current frame range for engine %s!" % engine)
Esempio n. 12
0
                if slider.Translation[1] > 2:
                    slider.Translation = FBVector3d(0, -2.5, 0)

    # Get the Hips Effector, select it and set Translation Reach to 100
    hips = FBFindModelByLabelName(nameSpace + "Character_Ctrl:HipsEffector")
    if hips:
        hips.Selected = True
        hips.PropertyList.Find("IK Blend T").Data = 100
else:
    # Find the hips skel joint
    hips = FBFindModelByLabelName(nameSpace + "Hips")
    if hips:
        hips.Selected = True

# Get the Translation nodes of the hips and zero out X and Y
hipsTransNodes = hips.Translation.GetAnimationNode().Nodes
ZeroTrans(hipsTransNodes)

# Get the Translation nodes of the Trajectory and zero out X and Y
# Trajectory is the EA nomenclature for the root joint
trajectory = FBFindModelByLabelName(nameSpace + "Trajectory")
if trajectory:
    trajTransNodes = trajectory.Translation.GetAnimationNode().Nodes
    ZeroTrans(trajTransNodes)

# "Scrub" the timeslider to update the scene
FBPlayerControl().GotoEnd()
FBPlayerControl().GotoStart()

# Clean up
del FBSystem, FBApplication, FBComponentList, FBVector3d, FBFindObjectsByName, FBFindModelByLabelName, FBPlayerControl
Esempio n. 13
0
def CreateNewTake(takeName):
    take = FBSystem().CurrentTake.CopyTake(takeName)
    take.ClearAllProperties(False)
    take.LocalTimeSpan = FBTimeSpan(FBTime(0), FBTime(0, 0, 0, 150))
    FBPlayerControl().GotoStart()
    return take