示例#1
0
def main(nBoids, bScale, nFrames, mSpeed, cWeight, cRadius, sWeight, sRadius, aWeight, aRadius, cBoxShowTarget, cBoxUseGoals, cBoxRandomVel):
	## set keyframe 0
	cmds.currentTime( 0 )

	## delete scene
	deleteAllObjects()

	## create boids
	boids_array = createBoids(nBoids)

	## create goal object
	goals = Goals()

	## get goals in scene
	goals_array = []
	if cBoxUseGoals:
		goals_array = goals.getGoals()

	## randomize positions
	firstKeyframe(boids_array, bScale, cBoxShowTarget, cBoxRandomVel)

	## simulate keyframes
	simulateKeyframes(boids_array, cRadius, sRadius, aRadius, nFrames, cWeight, sWeight, aWeight, mSpeed, goals_array, cBoxUseGoals, goals)

	cmds.playbackOptions(max=nFrames)
	cmds.playbackOptions(aet=nFrames)

	## play environment
	cmds.play()
示例#2
0
def startSpinSelected():
    cmds.group(n=‘SpinningGroup’)
    cmds.currentTime(1)
    cmds.playbackOptions(l=‘continuous’,ps=1)
    cmds.setKeyframe(‘SpinningGroup’, at=‘rotateY’, v=0, t=1)
    cmds.setKeyframe(‘SpinningGroup’, at=‘rotateY’, v=360, t=100)
    cmds.play(f=True)
def releaseProcedure(userInput):
	
	global initPlaybackSpeed
	
	mc.play( state = False)
	
	mc.playbackOptions(playbackSpeed = initPlaybackSpeed)
def cacheVP():
    """
    //Cache viewport geometry for playback

    undoInfo -stateWithoutFlush off;

    string $activePanel = `getPanel -wf`;
    modelEditor -e -grid false $activePanel;
    modelEditor -e -allObjects 0 $activePanel;
    modelEditor -e -polymeshes 1 $activePanel;

    int $rangeStartFrame = `playbackOptions -q -min`;

    currentTime -e $rangeStartFrame;
    playbackOptions -playbackSpeed 0 -loop "once" -by 1;
    playButtonForward;
    playbackOptions -playbackSpeed 1 -loop "continuous";

    undoInfo -stateWithoutFlush on;
    """

    cmds.undoInfo(swf=False)
    panType = cmds.getPanel(wf=True)
    cmds.modelEditor(panType, e=True, gr=False)
    cmds.modelEditor(panType, e=True, alo=False)
    cmds.modelEditor(panType, e=True, pm=True)

    rangeStartFrame = cmds.playbackOptions(q=True, min=True)

    cmds.currentTime = int(rangeStartFrame)
    cmds.playbackOptions(ps=0, l="once", by=1)
    cmds.play(f=True, ps=True)
    cmds.playbackOptions(ps=1, l="continuous")
    cmds.undoInfo(swf=True)
示例#5
0
def main(nBoids, bScale, nFrames, mSpeed, cWeight, cRadius, sWeight, sRadius,
         aWeight, aRadius, cBoxShowTarget, cBoxUseGoals, cBoxRandomVel):
    ## set keyframe 0
    cmds.currentTime(0)

    ## delete scene
    deleteAllObjects()

    ## create boids
    boids_array = createBoids(nBoids)

    ## create goal object
    goals = Goals()

    ## get goals in scene
    goals_array = []
    if cBoxUseGoals:
        goals_array = goals.getGoals()

    ## randomize positions
    firstKeyframe(boids_array, bScale, cBoxShowTarget, cBoxRandomVel)

    ## simulate keyframes
    simulateKeyframes(boids_array, cRadius, sRadius, aRadius, nFrames, cWeight,
                      sWeight, aWeight, mSpeed, goals_array, cBoxUseGoals,
                      goals)

    cmds.playbackOptions(max=nFrames)
    cmds.playbackOptions(aet=nFrames)

    ## play environment
    cmds.play()
def cacheVP():
    """
    //Cache viewport geometry for playback

    undoInfo -stateWithoutFlush off;

    string $activePanel = `getPanel -wf`;
    modelEditor -e -grid false $activePanel;
    modelEditor -e -allObjects 0 $activePanel;
    modelEditor -e -polymeshes 1 $activePanel;

    int $rangeStartFrame = `playbackOptions -q -min`;

    currentTime -e $rangeStartFrame;
    playbackOptions -playbackSpeed 0 -loop "once" -by 1;
    playButtonForward;
    playbackOptions -playbackSpeed 1 -loop "continuous";

    undoInfo -stateWithoutFlush on;
    """

    cmds.undoInfo(swf=False)
    panType = cmds.getPanel(wf=True)
    cmds.modelEditor(panType, e=True, gr=False)
    cmds.modelEditor(panType, e=True, alo=False)
    cmds.modelEditor(panType, e=True, pm=True)

    rangeStartFrame = cmds.playbackOptions(q=True, min=True)

    cmds.currentTime = int(rangeStartFrame)
    cmds.playbackOptions(ps=0, l="once", by=1)
    cmds.play(f=True, ps=True)
    cmds.playbackOptions(ps=1, l="continuous")
    cmds.undoInfo(swf=True)
示例#7
0
    def changeLayerMuteState(self, layerNameToChange, mute):
        """Change the muted state of the given animation layer if this exists.

        Args:
            layerNameToChange(str): the animation layer name to change
            mute(bool): mute state that will be applied to the given layer
        """

        # If the queried animation layer exists it will be muted
        if cmds.animLayer(layerNameToChange, query=True, exists=True):

            wasPlaying = False

            # Stop playback before doing any animation layer operation
            if cmds.play(query=True, state=True):
                cmds.play(state=False)
                wasPlaying = True

            # Change layer mute state
            cmds.animLayer(layerNameToChange, edit=True, mute=mute)

            if layerNameToChange == 'UpDown_1' and cmds.animLayer(
                    'UpDown_1', query=True, lock=True):
                cmds.animLayer('UpDown_1', edit=True, lock=False)

            # Once the operations have finished begin playback (only if it was playing before)
            if wasPlaying:
                cmds.play(state=True)
        else:
            logger.debug(layerNameToChange + " not found!")
示例#8
0
 def _maya_playback(self, state=None, forward=True):
     if state == None:
         state = not cmds.play(q=True, state=True)
     if state:
         cmds.play(forward=forward)
     else:
         cmds.play(state=state)
示例#9
0
    def changeLayerWeight(self, layerNameToChange, weight):
        """Change the weight of the given animation layer if this exists.

        Args:
            layerNameToChange(str): the animation layer name to change
            weight(float): weight that will be set to the given layer
        """

        # If the queried animation layer exists it will be muted
        if cmds.animLayer(layerNameToChange, query=True, exists=True):

            wasPlaying = False

            # Stop playback before doing any animation layer operation
            if cmds.play(query=True, state=True):
                cmds.play(state=False)
                wasPlaying = True

            # Change layer weight
            cmds.animLayer(layerNameToChange, edit=True, weight=weight)

            # Once the operations have finished begin playback (only if it was playing before)
            if wasPlaying:
                cmds.play(state=True)
        else:
            logger.debug(layerNameToChange + " not found!")
示例#10
0
def _playback(maxFrames=EMCORRECTNESS_MAX_FRAMECOUNT):
    """
    Run a playback sequence, starting at the first frame and going to
    the maxFrame requested.

    The only reason this is a separate method is so that the number of
    frames being played can be capped.
    """
    startFrame = cmds.playbackOptions(query=True, minTime=True)
    oldEndFrame = cmds.playbackOptions(query=True, maxTime=True)
    oldLoopType = cmds.playbackOptions(query=True, loop=True)
    oldFps = cmds.playbackOptions(query=True, fps=True)
    cmds.playbackOptions(loop='once')
    cmds.playbackOptions(fps=0)
    endFrame = oldEndFrame

    # If you have a scene with hugely long playback you don't want to be
    # waiting forever for the runs so limit the frame length to something
    # reasonable. (Or this could be recoded to make this an option.)
    if maxFrames > 0 and oldEndFrame - startFrame >= maxFrames:
        endFrame = startFrame + maxFrames - 1

    cmds.playbackOptions(maxTime=endFrame)
    cmds.currentTime(cmds.playbackOptions(query=True, minTime=True))
    cmds.play(wait=True)
    cmds.playbackOptions(maxTime=oldEndFrame)
    cmds.playbackOptions(loop=oldLoopType)
    cmds.playbackOptions(fps=oldFps)
    def tgpMakeBC(self, mshChar, deleteRight):
        startFrame = mc.playbackOptions(query=True, minTime=True)

        mc.currentTime(startFrame)
        mySel = mc.ls(sl=True)[0]  # my current selection

        mc.cutKey(mySel, s=True)  # delete key command
        # return
        records = ['tx', 'ty', 'tz', 'rx', 'ry', 'rz']
        for i in range(len(records)):
            name = "record{0}".format(i + 1)
            if mc.objExists(name):
                mc.delete(name)
            try:
                mc.setAttr("{0}.{1}".format(mySel, records[i]), 0)
            except:
                print("{0}.{1} could not be set".format(mySel, records[i]))

        # pyml.SetKeyTranslate()
        pyml.SetKey()
        currentUnitAngle = mc.currentUnit(q=True, a=True)
        mc.currentUnit(a="rad")

        mc.recordAttr(at=records)
        mc.play(record=True)
        mc.currentUnit(a=currentUnitAngle)
示例#12
0
文件: START.py 项目: gfixler/tomayto
 def __init__(self, mainInst):
     self.mainInst = mainInst
     self.keymap = {
         ('d', NOALT, NOCTRL, PRESS): ("RUN", cmds.delete),
         ('f', NOALT, NOCTRL, PRESS): ("RUN", cmds.viewFit),
         ('F', NOALT, NOCTRL, PRESS):
         ("RUN", lambda: cmds.viewFit(allObjects=True)),
         ('u', NOALT, NOCTRL, PRESS):
         ("RUN", lambda: cmds.evalDeferred(cmds.undo)),
         ('r', NOALT, CTRL, PRESS): ("RUN",
                                     lambda: cmds.evalDeferred(cmds.redo)),
         ('h', NOALT, NOCTRL, PRESS):
         ("RUN", lambda: cmds.play(state=True, forward=False)),
         ('h', NOALT, NOCTRL, RELEASE):
         ("RUN", lambda: cmds.play(state=False, forward=False)),
         ('l', NOALT, NOCTRL, PRESS): ("RUN",
                                       lambda: cmds.play(state=True)),
         ('l', NOALT, NOCTRL, RELEASE): ("RUN",
                                         lambda: cmds.play(state=False)),
         ('H', NOALT, NOCTRL, PRESS): ("RUN",
                                       lambda: cmds.currentTime(minTime())),
         ('L', NOALT, NOCTRL, PRESS): ("RUN",
                                       lambda: cmds.currentTime(maxTime())),
         ('M', NOALT, NOCTRL, PRESS):
         ("RUN", lambda: cmds.currentTime(round(
             (minTime() + maxTime()) / 2))),
         ('M', ALT, CTRL, PRESS): ("RUN", self.switchToMayaHotkeys),
         ('t', NOALT, NOCTRL, PRESS): ("PUSH", stateToolSelect),
         ('m', NOALT, NOCTRL, PRESS): ("PUSH", transform.stateMove),
         ('s', NOALT, NOCTRL, PRESS): ("PUSH", selection.stateSelect),
         ('v', NOALT, NOCTRL, PRESS): ("PUSH", vimline.stateVimline),
         ('V', NOALT, NOCTRL, PRESS): ("PUSH", vimline.stateVimlineTestWin),
     }
示例#13
0
def backflipAction(height):
    """quick and easy backflip to see your character in action."""
    
    # inatalize group and play options
    ms.group(n='flipper')
    ms.currentTime(1)
    ms.playbackOptions(l='continuous', ps=1, animationEndTime=25, max=25)
    
    # start / initalize flip action
    ms.setKeyframe('flipper', at='translateY', v=0, t=1)
    ms.setKeyframe('flipper', at='rotateX', v=0, t=1)
    ms.setKeyframe('flipper', at='scaleY', v=1, t=1)
    
    # mid / flip action
    ms.setKeyframe('flipper', at='translateY', v=-7, t=6)
    ms.setKeyframe('flipper', at='scaleY', v=0.8, t=6)
    ms.setKeyframe('flipper', at='rotateX', v=0, t=6)
    
    ms.setKeyframe('flipper', at='scaleY', v=1.3, t=10)
    ms.setKeyframe('flipper', at='translateY', v=height, t=16)
    ms.setKeyframe('flipper', at='scaleY', v=1, t=16)
    ms.setKeyframe('flipper', at='scaleY', v=1.3, t=20)
    
    # end / reset values
    ms.setKeyframe('flipper', at='translateY', v=0, t=24)
    ms.setKeyframe('flipper', at='rotateX', v=-360, t=24)
    ms.setKeyframe('flipper', at='scaleY', v=1, t=24)
    ms.setKeyframe('flipper', at='rotateX', v=0, t=25)
    
    ms.play(f=True, st=True)
示例#14
0
def releaseProcedure(userInput):

    global initPlaybackSpeed

    mc.play(state=False)

    mc.playbackOptions(playbackSpeed=initPlaybackSpeed)
示例#15
0
def simpleEmitter():
    cmds.file(force=True, newFile=True)
    cmds.currentUnit(linear='centimeter', angle='degree', time='film')

    # Load the plug-in emitter and create an emitter node
    cmds.loadPlugin('simpleEmitter.py')
    cmds.createNode('spSimpleEmitter', name='simpleEmitter')

    # Create particle object and connect to the plugin emitter node
    cmds.particle(name='particles')
    cmds.connectDynamic('particles', em='simpleEmitter')

    cmds.setAttr('simpleEmitter.rate', 200)
    cmds.setAttr('simpleEmitter.speed', 25)

    cmds.playbackOptions(minTime=0.00, maxTime=60.0)
    cmds.currentTime(0)
    cmds.play(wait=True, forward=True)

    # make some keyframes on emitter
    cmds.currentTime(0)
    cmds.select('simpleEmitter', replace=True)
    cmds.setKeyframe('simpleEmitter.tx')
    cmds.setKeyframe('simpleEmitter.ty')
    cmds.setKeyframe('simpleEmitter.tz')
    cmds.setKeyframe('simpleEmitter.rx')
    cmds.setKeyframe('simpleEmitter.ry')
    cmds.setKeyframe('simpleEmitter.rz')
    cmds.currentTime(30)
    cmds.move(-2.011944, 6.283524, -2.668834, relative=True)
    cmds.move(0,
              0,
              12.97635,
              relative=True,
              localSpace=True,
              worldSpaceDistance=True)
    cmds.rotate(0, -75.139762, 0, relative=True, objectSpace=True)
    cmds.setKeyframe('simpleEmitter.tx')
    cmds.setKeyframe('simpleEmitter.ty')
    cmds.setKeyframe('simpleEmitter.tz')
    cmds.setKeyframe('simpleEmitter.rx')
    cmds.setKeyframe('simpleEmitter.ry')
    cmds.setKeyframe('simpleEmitter.rz')
    cmds.currentTime(60)
    cmds.move(0, 0, -14.526107, relative=True)
    cmds.move(0, -8.130523, 0, relative=True)
    cmds.rotate(0, 0, 78.039751, relative=True, objectSpace=True)
    cmds.rotate(0, 0, 53.86918, relative=True, objectSpace=True)
    cmds.setKeyframe('simpleEmitter.tx')
    cmds.setKeyframe('simpleEmitter.ty')
    cmds.setKeyframe('simpleEmitter.tz')
    cmds.setKeyframe('simpleEmitter.rx')
    cmds.setKeyframe('simpleEmitter.ry')
    cmds.setKeyframe('simpleEmitter.rz')

    cmds.playbackOptions(minTime=0.00, maxTime=60.0)
    cmds.currentTime(0)
    cmds.play(wait=True, forward=True)
示例#16
0
def holdProcedure(userInput):

    global initPlaybackSpeed
    mc.playbackOptions(playbackSpeed=0)

    if userInput == True:
        mc.play(forward=True)
    elif userInput == False:
        mc.play(forward=False)
示例#17
0
 def wrapper(*args, **kwargs):
     playing = False
     if cmds.play(q=True, state=True):
         playing = True
         cmds.play(state=False)
     res = func(*args, **kwargs)
     if playing:
         cmds.play(forward=True)
     return res
示例#18
0
def animateFlower():

    cmds.playbackOptions(min=1, max=260)

    cmds.setKeyframe("petal", time=10, attribute="rotateX", value=0)
    cmds.setKeyframe("petal", time=1, attribute="translateY", value=0)
    cmds.setKeyframe("petal", time=24, attribute="rotateX", value=-55)
    cmds.setKeyframe("petal", time=48, attribute="translateY", value=-8)

    cmds.setKeyframe("petal5", time=10, attribute="rotateX", value=0)
    cmds.setKeyframe("petal5", time=1, attribute="translateY", value=0)
    cmds.setKeyframe("petal5", time=24, attribute="rotateX", value=-55)
    cmds.setKeyframe("petal5", time=48, attribute="translateY", value=-12)

    cmds.setKeyframe("petal4", time=34, attribute="rotateX", value=0)
    cmds.setKeyframe("petal4", time=25, attribute="translateY", value=0)
    cmds.setKeyframe("petal4", time=48, attribute="rotateX", value=-55)
    cmds.setKeyframe("petal4", time=96, attribute="translateY", value=-18)

    cmds.setKeyframe("petal9", time=34, attribute="rotateX", value=0)
    cmds.setKeyframe("petal9", time=25, attribute="translateY", value=0)
    cmds.setKeyframe("petal9", time=48, attribute="rotateX", value=-55)
    cmds.setKeyframe("petal9", time=96, attribute="translateY", value=-22)

    cmds.setKeyframe("petal8", time=58, attribute="rotateX", value=0)
    cmds.setKeyframe("petal8", time=49, attribute="translateY", value=0)
    cmds.setKeyframe("petal8", time=96, attribute="rotateX", value=-55)
    cmds.setKeyframe("petal8", time=120, attribute="translateY", value=-15)

    cmds.setKeyframe("petal7", time=106, attribute="rotateX", value=0)
    cmds.setKeyframe("petal7", time=97, attribute="translateY", value=0)
    cmds.setKeyframe("petal7", time=120, attribute="rotateX", value=-55)
    cmds.setKeyframe("petal7", time=168, attribute="translateY", value=-6)

    cmds.setKeyframe("petal3", time=130, attribute="rotateX", value=0)
    cmds.setKeyframe("petal3", time=121, attribute="translateY", value=0)
    cmds.setKeyframe("petal3", time=144, attribute="rotateX", value=-55)
    cmds.setKeyframe("petal3", time=216, attribute="translateY", value=-10)

    cmds.setKeyframe("petal1", time=130, attribute="rotateX", value=0)
    cmds.setKeyframe("petal1", time=121, attribute="translateY", value=0)
    cmds.setKeyframe("petal1", time=144, attribute="rotateX", value=-55)
    cmds.setKeyframe("petal1", time=216, attribute="translateY", value=-8)

    cmds.setKeyframe("petal6", time=154, attribute="rotateX", value=0)
    cmds.setKeyframe("petal6", time=145, attribute="translateY", value=0)
    cmds.setKeyframe("petal6", time=168, attribute="rotateX", value=-55)
    cmds.setKeyframe("petal6", time=264, attribute="translateY", value=-9)

    cmds.setKeyframe("petal2", time=178, attribute="rotateX", value=0)
    cmds.setKeyframe("petal2", time=169, attribute="translateY", value=0)
    cmds.setKeyframe("petal2", time=192, attribute="rotateX", value=-55)
    cmds.setKeyframe("petal2", time=312, attribute="translateY", value=-14)

    cmds.keyTangent(inTangentType='linear', outTangentType='linear')
    cmds.play(forward=True)
示例#19
0
 def play_timeline(self):
     if not cmds.play(q=True, state=True):
         self.timeline_settings = core.get_current_playback_settings()
         self.set_timeline()
         cmds.play(forward=True)
         self.play_clip_button.setIcon(self.pause_icon)
     else:
         cmds.play(state=False)
         cmds.playbackOptions(**self.timeline_settings)
         self.play_clip_button.setIcon(self.play_icon)
示例#20
0
def stopBackflip():
    """stop backflip action and clean up group / keys """
    
    ms.cutKey('flipper')
    ms.play(st=False)
    ms.scale(1,1,1,'flipper')
    ms.rotate(0,0,0, 'flipper')
    ms.move(0,0,0, 'flipper')
    ms.ungroup('flipper')
    ms.currentTime(1)
def holdProcedure(userInput):
	
	global initPlaybackSpeed
	mc.playbackOptions(playbackSpeed = 0)
	
	
	if userInput == True:
		mc.play( forward = True )
	elif userInput == False:
		mc.play( forward = False )
示例#22
0
def release():
    global lastFrame

    lastFrame = cmds.currentTime(q=True)

    mel.eval('invokeLastAction')

    if (time.time() - TIME_START) < 0.15:  # Quick button press
        if not isPlaying:
            cmds.playbackOptions(edit=True, playbackSpeed=playbackFPS / 24.0)
            cmds.play(state=True)
示例#23
0
def playAnim():
    global playSpeed
    global stepSpeed
    global maxSpeed
    print cmds.playbackOptions(q=True, mps=True)
    if cmds.play(q=True, state=True):
        cmds.play(st=False)
        print "pause "
    else:
        print "play"
        cmds.play(st=True)
示例#24
0
 def _play(self):
     """
     Responsible for interactive playback.
     """
     if self.play_button.text() == "PLAY":
         self.play_button.setText("STOP")
         self.play_button.setStyleSheet("background-color: red;")
         cmds.InteractivePlayback()
     elif self.play_button.text() == "STOP":
         self.play_button.setStyleSheet("background-color: light gray;")
         self.play_button.setText("PLAY")
         cmds.play(state=False)
示例#25
0
def simpleEmitter():
    cmds.file (force=True, newFile=True)
    cmds.currentUnit (linear='centimeter', angle='degree', time='film')

    # Load the plug-in emitter and create an emitter node
    cmds.loadPlugin ('simpleEmitter.py')
    cmds.createNode ('spSimpleEmitter', name='simpleEmitter')

    # Create particle object and connect to the plugin emitter node
    cmds.particle (name='particles')
    cmds.connectDynamic ('particles', em='simpleEmitter')

    cmds.setAttr ('simpleEmitter.rate', 200 )
    cmds.setAttr ('simpleEmitter.speed', 25 )

    cmds.playbackOptions (minTime=0.00, maxTime=60.0)
    cmds.currentTime (0)
    cmds.play (wait=True, forward=True)

    # make some keyframes on emitter
    cmds.currentTime (0)
    cmds.select ('simpleEmitter', replace=True)
    cmds.setKeyframe ('simpleEmitter.tx')
    cmds.setKeyframe ('simpleEmitter.ty')
    cmds.setKeyframe ('simpleEmitter.tz')
    cmds.setKeyframe ('simpleEmitter.rx')
    cmds.setKeyframe ('simpleEmitter.ry')
    cmds.setKeyframe ('simpleEmitter.rz')
    cmds.currentTime (30)
    cmds.move (-2.011944, 6.283524, -2.668834, relative=True)
    cmds.move (0, 0, 12.97635, relative=True, localSpace=True, worldSpaceDistance=True)
    cmds.rotate (0, -75.139762, 0, relative=True, objectSpace=True)
    cmds.setKeyframe ('simpleEmitter.tx')
    cmds.setKeyframe ('simpleEmitter.ty')
    cmds.setKeyframe ('simpleEmitter.tz')
    cmds.setKeyframe ('simpleEmitter.rx')
    cmds.setKeyframe ('simpleEmitter.ry')
    cmds.setKeyframe ('simpleEmitter.rz')
    cmds.currentTime (60)
    cmds.move (0, 0, -14.526107, relative=True)
    cmds.move (0, -8.130523, 0, relative=True)
    cmds.rotate (0, 0, 78.039751, relative=True, objectSpace=True)
    cmds.rotate (0, 0, 53.86918, relative=True, objectSpace=True)
    cmds.setKeyframe ('simpleEmitter.tx')
    cmds.setKeyframe ('simpleEmitter.ty')
    cmds.setKeyframe ('simpleEmitter.tz')
    cmds.setKeyframe ('simpleEmitter.rx')
    cmds.setKeyframe ('simpleEmitter.ry')
    cmds.setKeyframe ('simpleEmitter.rz')

    cmds.playbackOptions (minTime=0.00, maxTime=60.0)
    cmds.currentTime (0)
    cmds.play (wait=True, forward=True)
示例#26
0
 def _play(self):
     """
     Responsible for interactive playback.
     """
     if self.play_button.text() == "PLAY":
         self.play_button.setText("STOP")
         self.play_button.setStyleSheet("background-color: red;")
         cmds.InteractivePlayback()
     elif self.play_button.text() == "STOP":
         self.play_button.setStyleSheet("background-color: light gray;")
         self.play_button.setText("PLAY")
         cmds.play(state=False)
示例#27
0
def play_clip(play_button, start, end):
    if not start == '':
        if not end == '':   
            cmds.playbackOptions(min=start, ast=start)
            cmds.playbackOptions(max=end, aet=end)
        
            if cmds.play(q=True, state=True):
                cmds.play(state=False)
                cmds.symbolButton(play_button, e=True, image='playClip.png')
            else:
                cmds.play()
                cmds.symbolButton(play_button, e=True, image='stopClip.png')
def play_clip(play_button, start, end):
    if not start == '':
        if not end == '':
            change_range_start(start)
            change_range_end(end)

            if cmds.play(q=True, state=True):
                cmds.play(state=False)
                cmds.symbolButton(play_button, e=True, image='playClip.png')
            else:
                cmds.play()
                cmds.symbolButton(play_button, e=True, image='stopClip.png')
示例#29
0
 def addDressToSelected(self,*args):
     '''adds the dress particle system to the selected geo(s)'''
     dressType = 'all'
     defaultCount = self.ptcCount
     uniSeed = random.randrange(1, 360,1)
     selected = cmds.ls(sl = True)
     for surface in selected:
         (emitSurface, emitter, emitSurfPtcs, emitSurfPtcsShape,insterName) = self.createParticleBucket(surface,dressType,defaultCount)
         self.updateParticleBucket(emitSurfPtcsShape)
         self.makeDyanmic(emitter,emitSurfPtcs)
         self.createInstancer(insterName,emitSurfPtcsShape)
     if not cmds.play( q=True, state=True ):cmds.play( forward=True )
     return    
示例#30
0
    def gameStart(self, speed, recLen):
        self.timerLevel = int(20 / speed)

        cmds.currentTime(1)
        self.gameOverCount = -1
        self.recLen = recLen
        self.rec = {}
        for x in range(w):
            for y in range(h):
                coreName = '_' + str(x) + '_' + str(y)
                self.rec[coreName] = [1.0] * recLen
        self.spown()
        cmds.play(forward=1)
示例#31
0
def toggle():
    global firstFrame, lastFrame, isPlaying

    isPlaying = cmds.play(q=True, state=True)

    if isPlaying:  # Or else Maya will ignore the playhead
        cmds.play(state=False)

    cmds.currentTime(firstFrame)

    if isPlaying:
        cmds.play(state=True)

    firstFrame, lastFrame = lastFrame, firstFrame
示例#32
0
def run(numBoids, numFrames, boundaryName = 'boundary', locatorName = 'locator'):
	'''run the simulation'''
	nFrames = 5000
	global locator
	locator = locatorName
	boundary.setFromName(boundaryName)
	createBoids(numBoids)
	createObstacles()
	createKeyFrames(nFrames, boundary)

	cmds.playbackOptions(max=nFrames)
	cmds.playbackOptions(aet=nFrames)


	cmds.play()
示例#33
0
    def playAll():
        '''Playback the entire animation sequence, returning the elapsed time when it is done'''
        _dbg('*** playbackModeManager::playAll')
        cmds.currentTime(cmds.playbackOptions(query=True, minTime=True))
        start_time = cmds.timerX()
        cmds.play(wait=True)
        elapsed_time = cmds.timerX(startTime=start_time)

        if cmds.currentTime(query=True) != cmds.playbackOptions(query=True,
                                                                maxTime=True):
            _dbg('### ERR: Play All to {} ended on frame {}'.format(
                cmds.playbackOptions(query=True, maxTime=True),
                cmds.currentTime(query=True)))

        return elapsed_time
示例#34
0
def press():
    global TIME_START, isPlaying, firstFrame

    # Start the timer
    TIME_START = time.time()

    isPlaying = cmds.play(q=True, state=True)

    if isPlaying:
        cmds.play(state=False)
    else:
        firstFrame = cmds.currentTime(q=True)

    # The only annoying thing is the flashing in&out of the scrub context
    # whether or not we use it.
    # TODO: Investigate a workaround that doesn't use callbacks.
    mel.eval('storeLastAction( "restoreLastContext " + `currentCtx` )')
    cmds.setToolTo('TimeDragger')
示例#35
0
 def updatePtcSetting(self,*args):
     '''update the selected particle system based on the UI'''
     if cmds.ls(sl=True,dag = True, et='particle'):
         selPtc = cmds.ls(sl=True,dag = True, et='particle')
         ptcCount = cmds.intSliderGrp(self.ptcSlider, query = True, value = True)
         values= cmds.floatFieldGrp(self.ptcScaleGrp, query =True, value = True)
         randSeed = cmds.textFieldButtonGrp(self.ptcRandGrp, query = True, text = True)
         cmds.setAttr(selPtc[-1]+".maxCount",int(ptcCount))
         cmds.setAttr(selPtc[-1]+".scaleMin",float(values[0]))
         cmds.setAttr(selPtc[-1]+".scaleMax",float(values[1]))
         cmds.setAttr(selPtc[-1]+".randSeed",float(float(randSeed)))
         cmds.setAttr(selPtc[-1]+".seed[0]",int(int(randSeed)))
         self.updateParticleBucket(selPtc[-1])
         cmds.currentTime(cmds.playbackOptions( query = True, minTime = True ))
         if not cmds.play( q=True, state=True ):cmds.play( forward=True )
     else:
         print "Select a particle system"
     return
示例#36
0
def torusField():
	cmds.file(force=True, new=True)
	cmds.currentUnit(linear="centimeter", angle="degree", time="film")

	# Create the new field node
	cmds.createNode("spTorusField", name="torus")

	# create particle object.
	#
	cmds.particle(jbp=(0.0, 0.0, 0.0), nj=250, jr=5, c=1, name="particles")

	# connect torus field node with the particle object.
	#
	cmds.connectDynamic("particles", f="torus")
	cmds.setAttr("torus.attractDistance", 10)
	cmds.setAttr("torus.repelDistance", 5)

	cmds.playbackOptions(e=True, min=0.00, max=600.0)
	cmds.currentTime(0, e=True)
	cmds.play(wait=True, forward=True)
示例#37
0
def torusField():
    cmds.file(force=True, new=True)
    cmds.currentUnit(linear="centimeter", angle="degree", time="film")

    # Create the new field node
    cmds.createNode("spTorusField", name="torus")

    # create particle object.
    #
    cmds.particle(jbp=(0.0, 0.0, 0.0), nj=250, jr=5, c=1, name="particles")

    # connect torus field node with the particle object.
    #
    cmds.connectDynamic("particles", f="torus")
    cmds.setAttr("torus.attractDistance", 10)
    cmds.setAttr("torus.repelDistance", 5)

    cmds.playbackOptions(e=True, min=0.00, max=600.0)
    cmds.currentTime(0, e=True)
    cmds.play(wait=True, forward=True)
示例#38
0
def init(*args):
    """Funtion to call to start the script."""
    destroy_window()
    if cmds.play(q=True, state=True) is True:
        play_button()
    elif not prefs_play_all():
        play_button()
        log.info("Playback prefs set to update all viewports.")
    elif custom_viewport == "":
        draw_PlayView('PlayView')
    else:
        play_view(custom_viewport)
示例#39
0
def init(*args):
    """Funtion to call to start the script."""
    destroy_window()
    if cmds.play(q=True, state=True) is True:
        play_button()
    elif not prefs_play_all():
        play_button()
        log.info("Playback prefs set to update all viewports.")
    elif custom_viewport == "":
        draw_PlayView('PlayView')
    else:
        play_view(custom_viewport)
for s in range(0, 10):
    cmds.setAttr('pSphere2.scaleY', 1-((s%10)*0.1))
    cmds.setAttr('pSphere1.scaleY', 1-((s%10)*0.1)) 
    cmds.setKeyframe('pSphere2', 'pSphere1', attribute='scaleY', t=s)

for s in range(10, 20):
    cmds.setAttr('pSphere2.scaleY', 0+((s%10)*0.1))
    cmds.setAttr('pSphere1.scaleY', 0+((s%10)*0.1))
    cmds.setKeyframe('pSphere2', 'pSphere1', attribute='scaleY', t=s)

for s in range(20, 40):
    cmds.setAttr('pCylinder1.rotateZ', -20+((s%20)*4))
    cmds.setAttr('pSphere4.rotateZ', -14.894-((s%20)*50))
    cmds.setAttr('pSphere3.rotateZ', -14.894-((s%20)*50))    
    cmds.setKeyframe('pCylinder1', attribute='rotateZ', t=s)
    cmds.setKeyframe('pSphere4','pSphere3', attribute='rotateZ', t=s)


for s in range(40, 70):
    cmds.setAttr('pCylinder1.translateY', 4.618+((s%40)))
    cmds.setAttr('pSphere1.translateY', 4.537+((s%40)))
    cmds.setAttr('pSphere2.translateY', 4.537+((s%40)))
    cmds.setAttr('pSphere4.rotateZ', -14.894-((s%40)*50))
    cmds.setAttr('pSphere3.rotateZ', -14.894-((s%40)*50)) 
    cmds.setKeyframe('pCylinder1', 'pSphere1', 'pSphere2', attribute='translateY', t=s)
    cmds.setKeyframe('pSphere4','pSphere3', attribute='rotateZ', t=s)


cmds.play()
示例#41
0
 def recordStart(self):
     cmds.play(record=True)
示例#42
0
 def recordStop(self):
     cmds.play(state=False)
     self.removeAttrsToRecord(\
                 [attr.split('.')[-1] for attr in cmds.listAnimatable(cmds.ls(sl=True))])