def playblast_scene():
    """ Playblast the current scene using the min and max playback
    values as the start and end value for the playblast.

    :todo: Add a configuration (json) file that lets the user save
           their file to a particular location.
    :todo: Add a function in the utils folder that time stamps or
           versions the maya file.
    """
    # Get the start and end frames of the animation scene:
    start_frame = cmds.playbackOptions(min=True, query=True)
    end_frame   = cmds.playbackOptions(max=True, query=True)

    # Create the filename of the playblast:
    time_code = time.strftime("%Y_%m_%d_%H_%M_%S", time.localtime())

    filename = cmds.file(query=True, sceneName=True)
    filename += time_code
    filename += ".mov"

    location = os.path.join(_get_images_directory(), filename)

    # Playblast the scene:
    cmds.playblast(filename=location, fmt="qt", offScreen=True)

    # Return
    return
def zbw_stepAll():
    sel = cmds.ls(sl=True)
    keyList = []
    keySet = set()
    allKeys = []
    #get timeslider range start
    startF = cmds.playbackOptions(query=True, min=True)
    #get end frame
    endF = cmds.playbackOptions(query=True, max=True)
    #get all the keyed frames
    for this in sel:
        keyList = cmds.keyframe(this, query=True, time=(startF,endF))
        for key in keyList:
            key = int(key)
            keySet.add(key)
    #print keyList
    keySet = set(keyList)
    for frame in keySet:
        allKeys.append(frame)

    allKeys.sort()
    allKeys.reverse()
    #print allKeys

    for object in sel:
        for thisKey in allKeys:
            cmds.currentTime(thisKey)
            cmds.setKeyframe(object, t=thisKey, ott="step")
Example #3
0
def particleLocatorsUI():
    """
    """
    # Get current frame range
    start = cmds.playbackOptions(q=True, min=True)
    end = cmds.playbackOptions(q=True, max=True)

    # Define window
    particleLocatorsUI = 'particleLocatorsWindow'
    if cmds.window(particleLocatorsUI, q=True, ex=True): cmds.deleteUI(particleLocatorsUI)
    particleLocatorsUI = cmds.window(particleLocatorsUI, t='Generate Locators')

    # UI Layout
    cmds.columnLayout(adj=False, cal='left')
    partiTFG = cmds.textFieldGrp('partiLoc_particleTFG', label='Particle', text='', cw=[(1, 120)])
    prefixTFG = cmds.textFieldGrp('partiLoc_prefixTFG', label='Prefix', text='', cw=[(1, 120)])
    bakeAnicmdsBG = cmds.checkBoxGrp('partiLoc_bakeAnicmdsBG', label='Bake Animation', ncb=1, v1=0, cw=[(1, 120)])
    startEndIFG = cmds.intFieldGrp('partiLoc_startEndISG', nf=2, label='Frame Range', v1=start, v2=end, cw=[(1, 120)])

    rotateLocCBG = cmds.checkBoxGrp('partiLoc_rotateCBG', label='Rotate (rotatePP)', ncb=1, v1=0, cw=[(1, 120)])
    scaleLocCBG = cmds.checkBoxGrp('partiLoc_scaleCBG', label='Scale (scalePP)', ncb=1, v1=0, cw=[(1, 120)])

    cmds.button(l='Create Locators', c='glTools.tools.generateParticles.particleLocatorsFromUI()')

    # Popup menu
    cmds.popupMenu(parent=partiTFG)
    for p in cmds.ls(type=['particle', 'nParticle']):
        cmds.menuItem(p, c='cmds.textFieldGrp("' + partiTFG + '",e=True,text="' + p + '")')

    # Show Window
    cmds.showWindow(particleLocatorsUI)
Example #4
0
 def allFrame(self,*args):
     min = mc.playbackOptions(q=1, minTime=1)
     max = mc.playbackOptions(q=1, maxTime=1)
     nowFramHub = mc.currentTime( q=1 )
     allFrameHub = max -min
     frameHub = '%d/%d'%(nowFramHub,allFrameHub)
     return frameHub
def go():
    try:
        assetName, assetType, version = geo.decodeFileName()
    except IndexError:
        showErrorDialog()
        return

    if not assetType == 'animation':
        showErrorDialog()
        return

    fileName = mc.file(q=True, sceneName=True)
    dirName = os.path.dirname(fileName)
    source = amu.getCheckinDest(dirName)
    blastPath = os.path.join(os.path.dirname(source), 'playblasts')
    versionNum = amu.getLatestVersion(source)+1
    name = os.path.join(blastPath, assetName+"_v"+("%03d" % versionNum))

    startFrame = mc.playbackOptions(q=True, min=True)
    endFrame = mc.playbackOptions(q=True, max=True)

    choice = mc.confirmDialog( title = 'Playblast Tool'
                              , message       = 'What kind of playblast?'
                              , button        = ['Cancel', 'GL', 'Simple']
                              , defaultButton = 'Simple'
                              , cancelButton  = 'Cancel'
                              , dismissString = 'Cancel')
    if choice == 'Simple':
        simpleBlast(name, startFrame, endFrame)
    elif choice == 'GL':
        glBlast(name, startFrame, endFrame)
Example #6
0
 def get_keyspace(self):
     """Returns the space between the keys."""
     start = cmds.playbackOptions(q=True, minTime=True)
     end = cmds.playbackOptions(q=True, maxTime=True)
     total_keys = end - start
     width = self.timeline.geometry().width() - 5
     return width / (total_keys+1)
Example #7
0
def exportDeformAnimation(folder):
    '''Use MDD file to export defrom animation.'''
    minframe = int( mc.playbackOptions(q = True, min = True) )
    maxframe = int( mc.playbackOptions(q = True, max = True) )
    totalframes = maxframe - minframe + 1
    t = mc.currentUnit(q = True, t = True)
    fps = _mfps[t]
    
    parts = []
    selectionList = mo.MSelectionList()
    mo.MGlobal.getActiveSelectionList(selectionList)
    itList = mo.MItSelectionList(selectionList, mo.MFn.kTransform)
    while not itList.isDone():
        path = mo.MDagPath()
        itList.getDagPath(path)
        partialName = str(path.partialPathName())
        name = partialName.split(":")[-1]
        part = MDD(name, mo.MFnMesh(path), totalframes, fps)
        parts.append(part)
        itList.next()
    # add animation
    for frame in range(minframe, maxframe + 1):
        mc.currentTime(frame, edit = True)
        for p in parts:
            p.addFrame()
            
    # write files
    for p in parts:
        p.writeToFile(folder)
        print "write %s done." % p.name
    print "All is done."
    return True
Example #8
0
def outTime(newTime=None):
    if newTime != None and newTime != 0:
        mc.playbackOptions(maxTime=newTime, animationEndTime=newTime)
    elif newTime != None and newTime ==0:
        mc.playbackOptions(maxTime=newTime, animationEndTime=newTime)
    #return int(mc.playbackOptions(q=True, animationEndTime=True)) + 2
    return int(mc.playbackOptions(q=True, animationEndTime=True))
Example #9
0
def getMinMax():            
          
    rangeStart  = cmds.playbackOptions(query=True, minTime=True)
    rangeEnd    = cmds.playbackOptions(query=True, maxTime=True)
    curvesShown = cmds.animCurveEditor( 'graphEditor1GraphEd', query=True, curvesShown=True)
    keysTimes   = []
    keysValues  = []
    keysShown   = []
    
    if curvesShown:
        for aCurve in curvesShown:
            keysTimes.extend(cmds.keyframe(aCurve, query=True, timeChange=True))
            keysValues.extend(cmds.keyframe(aCurve, query=True, valueChange=True))
            for n, key in enumerate(keysTimes):
                if rangeStart <= key <= rangeEnd:
                    keysShown.append(keysValues[n])
                    
        keyMax = max(keysShown)
        keyMin = min(keysShown)
        total  = keyMax - keyMin
        if total == 0: total = 1
        border = total * .1
        
        return [keyMax+border, keyMin-border]
    else:
        return [0, 100]
Example #10
0
def load():
    '''loads animation environment'''
    print "loading animation environment presets..."
    #set autoKey
    cmds.autoKeyframe( state=True )
    #set 24fps and playback on all viewports
    cmds.playbackOptions(ps=1.0, v='all')
    #set unlimited undo's
    cmds.undoInfo( state=True, infinity=True )
    #set manipulator sizes
    if lib.checkAboveVersion(2014):
        cmds.manipOptions( r=False, hs=55, ls=4, sph=1 )
    else:
        cmds.manipOptions( r=False, hs=55, ls=4 )
    #set framerate visibility
    mel.eval("setFrameRateVisibility(1);")
    #gimbal rotation
    cmds.manipRotateContext('Rotate', e=True, mode=2)
    #world translation
    cmds.manipMoveContext('Move', e=True, mode=2)
    #time slider height
    aPlayBackSliderPython = mel.eval('$tmpVar=$gPlayBackSlider')
    cmds.timeControl(aPlayBackSliderPython, h=45, e=True);
    #special tick color
    cmds.displayRGBColor("timeSliderTickDrawSpecial", 1,0.5,0)

    #check if hotkeys have been set
    if (cmds.hotkey( 't', ctl=True, query=True, name = True)== 'CharacterAnimationEditorNameCommand'):
        print "Hotkeys have been previously loaded"
    else:
        setHotkeys('default')

    print "ENVIRONMENT SET\n", #the comma forces output on the status line
Example #11
0
def initializeBakeRange():
    """
    Initialize bake anim range based on playback timeline min/max.
    """
    start = cmds.playbackOptions(q=True, min=True)
    end = cmds.playbackOptions(q=True, max=True)
    cmds.intFieldGrp('xferMocap_startEndCBG', e=True, v1=start, v2=end)
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)
Example #13
0
def parse_active_scene():
    """Parse active scene for arguments for capture()

    *Resolution taken from render settings.

    """

    time_control = mel.eval("$gPlayBackSlider = $gPlayBackSlider")

    return {
        "start_frame": cmds.playbackOptions(minTime=True, query=True),
        "end_frame": cmds.playbackOptions(maxTime=True, query=True),
        "width": cmds.getAttr("defaultResolution.width"),
        "height": cmds.getAttr("defaultResolution.height"),
        "compression": cmds.optionVar(query="playblastCompression"),
        "filename": (cmds.optionVar(query="playblastFile")
                     if cmds.optionVar(query="playblastSaveToFile") else None),
        "format": cmds.optionVar(query="playblastFormat"),
        "off_screen": (True if cmds.optionVar(query="playblastOffscreen")
                       else False),
        "show_ornaments": (True if cmds.optionVar(query="playblastShowOrnaments")
                       else False),
        "quality": cmds.optionVar(query="playblastQuality"),
        "sound": cmds.timeControl(time_control, q=True, sound=True) or None
    }
Example #14
0
    def export_cameras(self, assets_path, project):
        valid_cameras = None
        selected_cameras = cmds.ls(sl=True, dag=True, ca=True)

        for cam in selected_cameras:
            if cam != "perspShape" and cam != "topShape" and cam != "frontShape" and cam != "sideShape":
                valid_cameras = True

        if not valid_cameras:
            cmds.inViewMessage(
                amg="No valid cameras selected (default 'persp' camera not supported in FBX export)",
                pos='botCenter', fade=True, fadeOutTime=500)
            return

        start_frame = str(cmds.playbackOptions(query=True, minTime=True))
        end_frame = str(cmds.playbackOptions(query=True, maxTime=True))

        if not os.path.exists(assets_path + "/" + project):
            os.makedirs(assets_path + "/" + project)

        output_file = assets_path + "/" + project + "/" + project + "_cameras.fbx"

        print "Camera file name: " + output_file

        # save the cameras to assets folder
        maya.mel.eval('FBXExportFileVersion "FBX201200"')
        maya.mel.eval('FBXExportInAscii -v true')
        maya.mel.eval("FBXExportCameras -v true")
        cmds.file(output_file, force=True, options='v=0', type='FBX export', pr=True, es=True)

        return [output_file, start_frame, end_frame]
Example #15
0
def go():
    try:
        assetName, assetType, version = geo.decodeFileName()
    except IndexError:
        showErrorDialog()
        return

    if not assetType == "animation":
        showErrorDialog()
        return

    fileName = mc.file(q=True, sceneName=True)
    dirName = os.path.dirname(fileName)
    source = amu.getCheckinDest(dirName)
    blastPath = os.path.join(os.path.dirname(source), "playblasts")
    name = os.path.join(blastPath, assetName)

    startFrame = mc.playbackOptions(q=True, min=True)
    endFrame = mc.playbackOptions(q=True, max=True)

    choice = mc.confirmDialog(
        title="Playblast Tool",
        message="What kind of playblast?",
        button=["Cancel", "GL", "Simple"],
        defaultButton="Simple",
        cancelButton="Cancel",
        dismissString="Cancel",
    )
    if choice == "Simple":
        simpleBlast(name, startFrame, endFrame)
    elif choice == "GL":
        glBlast(name, startFrame, endFrame)
 def LoadJointMotionPaths( self, roots ):
     """ prep the data structure that holds the motion paths """
     animPaths = {}
     for root in roots:
         animPaths[root] = {}
         self.trace[root] = Trajectory("%sTrace"%root)
         # find all nearby joints
         joints = [j for j in mc.listRelatives( root, allDescendents=True ) if j in self.traceableObjs]  # TODO: just get the nearby joints by projecting them all onto the viewing plane and finding the distance
         # get the motion path of each nearby joint
         if len(joints) > 0:
             for j in joints:
                 animPaths[root][j] = Trajectory( "%s_path"%j )
                 if debug > 0:
                     mc.group(name="%sGrp"%j,empty=True)
     
     startFrame = mc.playbackOptions(q=True,minTime=True)
     endFrame = mc.playbackOptions(q=True,maxTime=True)+1
     for t in [float(x)/self.substeps+startFrame for x in range(0, int(endFrame-startFrame)*self.substeps)]:
         mc.currentTime(t)
         for root in roots:
             joints = [j for j in mc.listRelatives( root, allDescendents=True ) if j in self.traceableObjs]
             for j in joints:
                 point = Vector( mc.xform(j, q=True, ws=True, t=True) ) 
                 animPaths[root][j].AddPoint( point, t )
                 if debug > 0:
                     loc = mc.spaceLocator(p=point)
                     mc.parent(loc,"%sGrp"%j)
             self.trace[root].SetSearchList( animPaths[root] )
Example #17
0
    def __init__(self, resolution=[1920, 1080, 1.0], range=[]):
        self.userName = "******"
        self.resolution = resolution
        self.curPanel = cmds.getPanel(wf=True)

        self.userName = "******"
        self.settings = fn.loadSettings(fileName)
        if "display" in self.settings:
            self.userName = self.settings["display"]

        curDate = time.localtime()
        self.curTime = "%02d:%02d %02d.%02d.%04d" % (
            curDate.tm_hour,
            curDate.tm_min,
            curDate.tm_mday,
            curDate.tm_mon,
            curDate.tm_year,
        )

        if range:
            self.range = range
        else:
            self.range = [cmds.playbackOptions(q=True, min=True), cmds.playbackOptions(q=True, max=True)]
        self.duration = int(self.range[1] - self.range[0] + 1)

        self.getFileName()
        self.getFPS()
    def TraceGestureRelease( self ):
        """ when the mouse is released, find the matching joint trajectory """
        if debug>0: print("begin RELEASE")
        releasePosition = Vector( mc.draggerContext( 'TraceGesture', query=True, dragPoint=True) ).projectToPlane( self.trace[self.nearestRoot].normal, planePt=self.trace[self.nearestRoot].planePt )
        if debug>0: print "release! ", releasePosition
        theTrace = self.trace[self.nearestRoot]
        selectedMotion = None
        if theTrace.closestJoint and theTrace.timespan and (theTrace.timespan[1]-theTrace.timespan[0]) > 1 and \
           not mc.draggerContext( 'TraceGesture', query=True, modifier=True) == "ctrl":        
            theDTW = theTrace.dtws[theTrace.closest]
            if debug > 0:
                print "closest = ", theTrace.closestJoint, theTrace.timespan
                if not mc.objExists("DTW_Y"):
                    mc.group(n="DTW_Y",empty=True)
                for pt in theDTW.Y:
                    loc = mc.spaceLocator(p=pt)
                    mc.parent(loc,"DTW_Y")
        ##    ghostJoint(trace[nearestRoot].closestJoint,trace[nearestRoot].timespan)

            # Build the motion curve and store it's name in the selectedMotions dictionary
            duration = [ int(theTrace.timespan[0]), int(theTrace.timespan[1]+1) ]
            keyframes = [ theTrace.searchList[theTrace.closestJoint].points[frame] for frame in range(duration[0],duration[1]) ]
            selectedMotion = bmt.CurveMotionTrace( theTrace.closestJoint, keys=keyframes ) #duration=theTrace.timespan )
            
        else:
            self.ScrubToNearestTimeOnPath( releasePosition, self.nearestRoot, self.nearestPath )
            cam2pop = self.CameraToPopDist()
            path = theTrace.searchList[self.nearestPath]
            pointKey = path.ClosestTimeTo(releasePosition)
            closestPoint = path.points[pointKey]
            closestPtOnPath = closestPoint.projectToPlane( theTrace.normal, planePt=theTrace.planePt )
            mouse2path = (releasePosition - closestPtOnPath).mag()
            # if motion paths are visible and no drag happened
            # and releasePosition is very close to the path,
            # then select the whole motion path
            if self.motionPathsVisible[self.nearestRoot] and mouse2path < 0.3:  
                # Build the motion curve and store it's name in the selectedMotions dictionary
                duration = [ mc.playbackOptions(q=True,min=True),mc.playbackOptions(q=True,max=True)+1 ]
                keyframes = [ theTrace.searchList[self.nearestPath].points[frame] for frame in range(duration[0],duration[1]) ]
                selectedMotion = bmt.CurveMotionTrace( self.nearestPath, keys=keyframes ) #duration=[mc.playbackOptions(q=True,min=True),mc.playbackOptions(q=True,max=True)] )

            # if not scrubbing
            if not mc.draggerContext( 'TraceGesture', query=True, modifier=True) == "ctrl" and \
               cam2pop >= self.viewFitDistance:      # if trucked out, and mouse is clicked (w/ no drag)
                mc.select(self.nearestRoot)     # zoom in on the nearest root for a better view
                mc.viewFit(fitFactor=2.5)            # the invisible parts of the roots can artificially enlarge the BB, so truck in a little extra
                mc.select(clear=True)
        if selectedMotion:
            selectedMotionCurve = selectedMotion.construct(self.nearestPath)
            
            if not self.nearestRoot in self.selectedMotions.keys():
                self.selectedMotions[self.nearestRoot] = []
            mc.setAttr("%s_MotionTraces.visibility"%self.nearestRoot, 0)
            selectedMotionCurve = mc.rename(selectedMotionCurve, "%s_selection%d"%(self.nearestPath,len(self.selectedMotions[self.nearestRoot])))
            self.selectedMotions[self.nearestRoot].append( selectedMotionCurve )
            self.AddCustomAttr( selectedMotionCurve, "isTraceSelection", True )
            self.AddCustomAttr( selectedMotionCurve, "interactTime", time.time()-self.startTime )
            self.AddCustomAttr( selectedMotionCurve, "startFrame", duration[0] )
            self.AddCustomAttr( selectedMotionCurve, "endFrame", duration[1] )
        mc.select(cl=True)
Example #19
0
 def setTimelineRange(self, range=None, *args):  
        
     rangeVisible            = cmds.timeControl( G.playBackSliderPython, query=True, rangeVisible=True )
     
     if not rangeVisible and not range:
         range = [cmds.playbackOptions(query=True, minTime=True), cmds.playbackOptions(query=True, maxTime=True)+1]
     
     if range or rangeVisible:
   
         if not range: range = animMod.getTimelineRange(float=False)
         rFrom   = range[0]
         rTo     = range[1]-1
         
         cmds.playbackOptions(minTime=rFrom, maxTime=rTo)
         
         
         if self.getTimelineRanges() != None: 
             ranges = eval(self.getTimelineRanges()) 
         else: 
             ranges = []
         if not range in ranges:
             ranges.append(range)     
             aToolsMod.saveInfoWithScene(STORE_NODE, RANGE_ATTR, ranges) 
             
     
     utilMod.deselectTimelineRange()
Example #20
0
 def populateMenu(self, menu, *args):
     uiMod.clearMenuItems(menu)
     uiMod.clearMenuItems(menu)
     #cmds.menuItem(label="Clear motion trails", command=self.clear)
     cmds.radioMenuItemCollection(parent=menu)
     
     currRange    = [cmds.playbackOptions(query=True, minTime=True), cmds.playbackOptions(query=True, maxTime=True)]
     currRangeStr = "%s   -   %s"%(int(currRange[0]), int(currRange[1]))            
      
     #populate list
     ranges = self.getTimelineRanges()
     if ranges: ranges   = eval(ranges)
     if ranges:
         for loopRange in ranges:
             loopRangeStr    = "%s   -   %s"%(int(loopRange[0]), int(loopRange[1]-1))                                
             radioButton     = (currRangeStr == loopRangeStr)
             cmds.menuItem("menu_%s"%loopRange, radioButton=radioButton, label=loopRangeStr, parent=menu, command=lambda x, loopRange=loopRange, *args: self.setTimelineRange(loopRange))
         cmds.menuItem( divider=True, parent=menu)   
         newMenu = cmds.menuItem(subMenu=True, label='Delete', parent=menu) 
         cmds.menuItem( divider=True, parent=menu)  
         for loopRange in ranges:
             loopRangeStr = "%s   -   %s"%(int(loopRange[0]), int(loopRange[1]-1))
             cmds.menuItem("menu_%s"%loopRange, label=loopRangeStr, parent=newMenu, command=lambda x, loopRange=loopRange, *args: self.deleteTimelineRange(loopRange))
         cmds.menuItem( divider=True, parent=newMenu)       
         cmds.menuItem("menu_deleteAll", label="Delete All", parent=newMenu, command=self.deleteAllTimelineRange)
     cmds.menuItem("toggleLipSyncModeMenu", label='Lip Sync Mode', checkBox=self.isLipSyncMode(), command=self.toggleLipSyncMode, parent=menu) 
Example #21
0
 def getCurrent(self):
     self.minframe = int( mc.playbackOptions(q = True, min = True) )
     self.maxframe = int( mc.playbackOptions(q = True, max = True) )
     self.totalframes = self.maxframe - self.minframe + 1
     t = mc.currentUnit(q = True, t = True)
     self.fps = self._mfps[t]
     return True
Example #22
0
 def __init__(self, shotAssetPath, shot):
     super(CameraExportWidget, self).__init__()
     self.setLayout(QtGui.QVBoxLayout())
     widgetLayout = QtGui.QGridLayout()
     self.layout().addLayout(widgetLayout)
     widgetLayout.addWidget(QtGui.QLabel('Select Camera:'), 0, 0)
     self.cameraBox = QtGui.QComboBox()
     self.populateCameraBox()
     widgetLayout.addWidget(self.cameraBox, 0, 1)
     widgetLayout.addWidget(QtGui.QLabel('Frame Start'), 1, 0)
     self.frameStartEdit = QtGui.QLineEdit()
     self.frameStartEdit.setText(str(cmds.playbackOptions(q=True, minTime=True)))
     widgetLayout.addWidget(self.frameStartEdit, 1, 1)
     widgetLayout.addWidget(QtGui.QLabel('Frame End'), 1, 2)
     self.frameEndEdit = QtGui.QLineEdit()
     self.frameEndEdit.setText(str(cmds.playbackOptions(q=True, maxTime=True)))
     widgetLayout.addWidget(self.frameEndEdit, 1, 3)
     widgetLayout.addWidget(QtGui.QLabel('Frame Step'), 2, 0)
     self.frameStepEdit = QtGui.QLineEdit()
     self.frameStepEdit.setText('1')
     widgetLayout.addWidget(self.frameStepEdit, 2, 1)
     fileLayout = QtGui.QHBoxLayout()
     fileLayout.addWidget(QtGui.QLabel('Output File:'))
     self.outFileEdit = QtGui.QLineEdit()
     camFilePath = ''
     if shotAssetPath and shot:
         camFilePath = self.getOutputFilename(shot, shotAssetPath)
     self.outFileEdit.setText(camFilePath)
     fileLayout.addWidget(self.outFileEdit)
     toolButton = QtGui.QToolButton()
     toolButton.setText('...')
     toolButton.clicked.connect(lambda: self.saveOutputFilename(camFilePath))
     fileLayout.addWidget(toolButton)
     self.layout().addLayout(fileLayout)
Example #23
0
 def set_frame_range(self, startFrame, endFrame):
     if endFrame <= startFrame:
         startFrame = cmds.playbackOptions(query=True, min=True)
         endFrame = cmds.playbackOptions(query=True, max=True)
         
     cmds.setAttr('defaultRenderGlobals.startFrame', startFrame)
     cmds.setAttr('defaultRenderGlobals.endFrame', endFrame)
def exportAlembic():
	
	msgText = ""

	SAVE_PATH       = os.path.dirname(cmds.file(q=True,sn=True))
	SAVE_PATH		= SAVE_PATH.replace("WORK", "PUBLISH")
	SAVE_FILE     	= os.path.basename(cmds.file(q=True,sn=True))

	if (len(SAVE_FILE.split('_')) > 2):
		tmpFile = SAVE_FILE.split('_')
		SAVE_FILE = tmpFile[0] + "_" + tmpFile[1]

	SAVE_DIR		= (SAVE_PATH + '\\' + SAVE_FILE.split('.')[0] + ".abc").replace("\\","/")

	FRAME_START		= cmds.playbackOptions( query=True, animationStartTime=True )
	FRAME_END		= cmds.playbackOptions( query=True, animationEndTime=True )


	try:
		mel.eval('select -r ASSETS ;')
		mel.eval('select -add CAM ;')
		mel.eval('AbcExport -j "-frameRange ' + str(FRAME_START) + ' ' + str(FRAME_END) + ' -attr name -dataFormat hdf -root |ASSETS -root |CAM -file ' + SAVE_DIR + '";')
		msgText = "** DONE | ALEMBIC EXPORT: " + SAVE_DIR.replace("/","\\") + " **"
		print(msgText)  

	except:
		msgText = "** FAIL | ALEMBIC EXPORT: No ASSETS & CAM group in the scene **"
		print(msgText)  

	return msgText
Example #25
0
def importCache( mesh, xmlFilePath ):
    
    mesh = sgModelDag.getShape( mesh )
    
    xmlFileSplits = xmlFilePath.split( '/' )
    cachePath = '/'.join( xmlFileSplits[:-1] )
    cacheName = xmlFileSplits[-1].split( '.' )[0]
    
    deformer = cmds.createNode( 'historySwitch' )
    cacheNode = cmds.createNode( 'cacheFile' )
    
    cmds.connectAttr( cacheNode+'.outCacheData[0]', deformer+'.inPositions[0]')
    cmds.connectAttr( cacheNode+'.inRange',         deformer+'.playFromCache' )
    cmds.connectAttr( 'time1.outTime', cacheNode+'.time' )
    
    cmds.setAttr( cacheNode+'.cachePath', cachePath, type='string' )
    cmds.setAttr( cacheNode+'.cacheName', cacheName, type='string' )
    
    #print "xml filePath : ", xmlFilePath
    startFrame, endFrame = sgModelData.getStartAndEndFrameFromXmlFile( xmlFilePath )
    cmds.playbackOptions( animationStartTime = startFrame, animationEndTime= endFrame,
                          minTime = startFrame+5, maxTime= endFrame-5 )
    
    cmds.setAttr( cacheNode+'.startFrame',    startFrame )
    cmds.setAttr( cacheNode+'.sourceStart',   startFrame )
    cmds.setAttr( cacheNode+'.sourceEnd',     endFrame )
    cmds.setAttr( cacheNode+'.originalStart', startFrame )
    cmds.setAttr( cacheNode+'.originalEnd',   endFrame )

    origMesh = sgModelDag.getOrigShape( mesh )
    if not origMesh: return None
    
    cmds.connectAttr( origMesh+'.worldMesh', deformer+'.undeformedGeometry[0]' )
    cmds.connectAttr( deformer+'.outputGeometry[0]', mesh+'.inMesh', f=1 )
    def process(self, instance):
        self.log.info("Extracting capture..")

        current_min_time = cmds.playbackOptions(minTime=True, query=True)
        current_max_time = cmds.playbackOptions(maxTime=True, query=True)

        default_width = cmds.getAttr("defaultResolution.width")
        default_height = cmds.getAttr("defaultResolution.height")

        width = instance.data('width') or default_width
        height = instance.data('height') or default_height
        start_frame = instance.data('startFrame') or current_min_time
        end_frame = instance.data('endFrame') or current_max_time

        format = instance.data('format') or 'qt'
        compression = instance.data('compression') or 'h264'
        off_screen = instance.data('offScreen', False)
        maintain_aspect_ratio = instance.data('maintainAspectRatio', True)

        # Set viewport settings
        view_opts = capture.ViewportOptions.copy()
        view_opts.update({
            "displayAppearance": "smoothShaded",
            "polymeshes": True,
            "nurbsSurfaces": True
        })

        cameras = [c for c in instance if cmds.nodeType(c) == "camera"]
        cameras = [cmds.listRelatives(c, parent=True)[0] for c in cameras]

        path = self.temp_dir(instance)

        for camera in cameras:
            # Ensure name of camera is valid
            camera = pyblish.api.format_filename(camera)

            if format == 'image':
                # Append sub-directory for image-sequence
                path = os.path.join(path, camera)
            else:
                path = os.path.join(path, camera + ".mov")

            self.log.info("Outputting to %s" % path)

            output = capture.capture(
                filename=path,
                camera=camera,
                width=width,
                height=height,
                start_frame=start_frame,
                end_frame=end_frame,
                format=format,
                viewer=False,
                compression=compression,
                off_screen=off_screen,
                maintain_aspect_ratio=maintain_aspect_ratio,
                viewport_options=view_opts)

            self.log.info("Outputted to: %s" % output)
            instance.set_data("reviewOutput", output)
Example #27
0
def bakeDynamicCmd(*args):
    '''
    Bake the dynamic simulation as key frames on the joints rotations for the specified frame range
    '''
    # display warning message
    result = cmds.confirmDialog(messageAlign="left", title="Bake Simulation", message="Baking simulation will replace the dynamics\nfor keyframe animation. Action is undoable. Do you wish to continue?", button=["Yes", "No"])
     
    if result == "Yes":
        # get selected object
        selected = cmds.ls(sl=True)
         
        if selected:
            # manage the dynamic node
            dNode = lpDynamicChain(node=selected[0])
            startJoint = dNode.startJoint[0]
            endJoint = dNode.endJoint[0]
             
            # get frame range
            startFrame = cmds.intFieldGrp("frameRangeIFG", q=True, v1=True)
            endFrame = cmds.intFieldGrp("frameRangeIFG", q=True, v2=True)
             
            if cmds.checkBoxGrp("useTimeSliderCBG", q=True, v1=True):
                startFrame = cmds.playbackOptions(q=True, minTime=True)
                endFrame = cmds.playbackOptions(q=True, maxTime=True)
             
            # get the joints
            joints = [startJoint]
            joints.extend( findAllJointsFromTo(startJoint, endJoint) )
             
        # bake the simulation for the frame range - this action is undoable
        cmds.bakeResults(joints, t=(startFrame, endFrame), dic=False, preserveOutsideKeys=True, simulation=True)
Example #28
0
    def timeline(self):

        minT = cmds.playbackOptions(q=True, min=True)
        maxT = cmds.playbackOptions(q=True, max=True)

        self.start_lineEdit.setText(str(minT))
        self.end_lineEdit.setText(str(maxT))
Example #29
0
 def _plotter_avrg(self):
     '''plots a locator to a vertice or face per keyframe in a timeline'''
     selObj=cmds.ls(sl=1, fl=1)      
     if len(selObj)>0:
         pass
     else:
         print "Select 1 object" 
         return     
     getTopRange=cmds.playbackOptions(q=1, max=1)+1#get framerange of scene to set keys in iteration 
     getLowRange=cmds.playbackOptions(q=1, min=1)-1#get framerange of scene to set keys in iteration 
     edgeBucket=[]
     getRange=arange(getLowRange,getTopRange, 1 )
     getloc=cmds.spaceLocator(n=selObj[0]+"cnstr_lctr")
     cmds.normalConstraint(selObj[0], getloc[0])
     placeloc=cmds.spaceLocator(n=selObj[0]+"lctr")
     for each in getRange:
         cmds.currentTime(each)            
         transform=cmds.xform(selObj, q=1, ws=1, t=1)
         posBucketx=self.array_median_find(transform[0::3])
         posBuckety=self.array_median_find(transform[1::3])
         posBucketz=self.array_median_find(transform[2::3])
         cmds.xform(getloc[0], ws=1, t=(posBucketx, posBuckety, posBucketz))  
         cmds.SetKeyTranslate(getloc[0])
         cmds.xform(placeloc[0], ws=1, t=(posBucketx, posBuckety, posBucketz))
         cmds.SetKeyTranslate(placeloc[0])               
         rotate=cmds.xform(getloc[0], q=True, ws=1, ro=True)
         cmds.xform(placeloc[0], ws=1, ro=rotate)  
         cmds.SetKeyRotate(placeloc[0])
         cmds.currentTime(each)            
    def setAttrsFromModInfo(self, animModAttrSettings): 
        allAnimNodes = [] 
        print ' SetAttrFromModInfo'   
        for each in animModAttrSettings:
            
            attribute = each[0]
            value = float(each[1])

            if attribute != 'endFrame':   
                """ Strip the attribute down to the node name""" 
                """so we can verify it exists """           
                animNode = self.stripAttrNameFromGrp(attribute)

                
            
 
                if cmds.objExists(animNode) == True:
                    try:
                        cmds.setAttr(attribute, value)
                    except: 
                        print (attribute + " .........could not be set ")
                    #else:
                        #try:
                            #self.installAnimModFromCsv(animNode)
                        #except:
                            #pass
                        
            else:
                cmds.playbackOptions( minTime='0sec', maxTime=value)
Example #31
0
    def compute(self, plug, dataBlock):

        outsAttr = [self.outputTAttr, self.outputRAttr, self.outputSAttr]
        if not (plug in outsAttr):
            return om.kUnknownParameter

        trsObj = trsClass.trsClass()
        # _________________________________ IN MATRIX
        masterTrs = []

        arrayDataHandle = om.MArrayDataHandle(
            dataBlock.inputValue(self.inputMatrixAttr))

        for i in range(arrayDataHandle.elementCount() - 1):
            arrayDataHandle.next()
            floatMatrix = (arrayDataHandle.inputValue()).asFloatMatrix()
            masterTrs.append(
                trsObj.createFromFloatMatrix(MMatrixToNum(floatMatrix)))

        # _________________________________ IN DYN ATTR

        dataHandle = dataBlock.inputValue(self.inputTimeAttr)
        intime = dataHandle.asFloat()

        dataHandle = dataBlock.inputValue(self.inputActivateAttr)
        activate = dataHandle.asFloat()

        dataHandle = dataBlock.inputValue(self.input1Attr)
        mass = dataHandle.asFloat()

        dataHandle = dataBlock.inputValue(self.input2Attr)
        elasticity = dataHandle.asFloat()

        dataHandle = dataBlock.inputValue(self.input3Attr)
        damping = dataHandle.asFloat()

        dataHandle = dataBlock.inputValue(self.input4Attr)
        gravity = dataHandle.asFloat()

        # _________________________________ SAVE NEXT EVAL

        dataHandle = dataBlock.inputValue(self.inputNext1Attr)
        self.nbrEval = dataHandle.asFloat()

        dataHandle = dataBlock.inputValue(self.inputNext2Attr)
        self.lastTime = dataHandle.asFloat()

        dataHandle = dataBlock.inputValue(self.inputNext3Attr)
        self.lastSpeed = dataHandle.asFloat3()
        self.lastSpeed = [
            self.lastSpeed[0], self.lastSpeed[1], self.lastSpeed[2]
        ]

        self.slavesValues = []

        arrayDataHandle = om.MArrayDataHandle(
            dataBlock.inputValue(self.inputNext4Attr))

        for i in range(arrayDataHandle.elementCount() - 1):
            arrayDataHandle.next()
            slaveValue = (arrayDataHandle.inputValue()).asFloat3()
            self.slavesValues.append(
                [slaveValue[0], slaveValue[1], slaveValue[2]])

        #_____________________________________________________________________________________COMPUTE

        gravityVector = [0, gravity, 0]

        #_______________ DELTA TIME
        incrEval = 0.04
        self.nbrEval += incrEval

        curTime = self.nbrEval
        deltaTime = curTime - self.lastTime
        self.lastTime = curTime

        #_______________ DYNAMIC
        curentFrame = mc.currentTime(query=True)
        startFrame = mc.playbackOptions(query=True, minTime=True)

        if (activate == 0) or (curentFrame == startFrame):

            self.nbrEval = 0
            self.lastTime = 0
            self.lastSpeed = [0, 0, 0]

            self.slavesValues = []
            for i in range(0, len(masterTrs)):
                self.slavesValues.append(masterTrs[i][0:3])

            for i in range(1, len(masterTrs)):
                leadPos = masterTrs[i - 1]
                slavePos = masterTrs[i]
                baseLengths[i] = ompy.MVector(
                    slavePos[0] - leadPos[0], slavePos[1] - leadPos[1],
                    slavePos[2] - leadPos[2]).length()

        else:

            # FOLLOW DYN
            self.slaveValue[0] = inMatrices[0][0:3]

            for i in range(1, len(masterTrs)):
                leadPos = self.slavesValues[i - 1]
                slavePos = self.slavesValues[i]

                vLeadSlave = ompy.MVector(slavePos[0] - leadPos[0],
                                          slavePos[1] - leadPos[1],
                                          slavePos[2] - leadPos[2])
                vLeadSlaveAdjust = vLeadSlave * (baseLengths[i] /
                                                 vLeadSlave.length())
                slavePosNew = [
                    leadPos[0] + vLeadSlaveAdjust.x,
                    leadPos[1] + vLeadSlaveAdjust.y,
                    leadPos[2] + vLeadSlaveAdjust.z
                ]

                self.slavesValues[i] = slavePosNew

        translate = self.slaveValue
        rotate = [0, 0, 0]
        scale = [1, 1, 1]

        #_____________________________________________________________________________________ OUT NEXT

        nodeName = self.name()
        mc.undoInfo(swf=0)

        mc.setAttr(nodeName + '.' + self.kInputNext1AttrName, self.nbrEval)
        mc.setAttr(nodeName + '.' + self.kInputNext2AttrName, self.lastTime)
        #mc.setAttr( nodeName +'.'+ self.kInputNext3AttrName  , self.lastSpeed[0] ,  self.lastSpeed[1] ,  self.lastSpeed[2] , type = 'double3')

        for i in range(0, len(self.slavesValues)):
            mc.setAttr(nodeName + '.' + self.kInputNext4AttrName +
                       '[{0}]'.format(i),
                       self.slavesValues[i][0],
                       self.slavesValues[i][1],
                       self.slavesValues[i][2],
                       type='double3')

        mc.undoInfo(swf=1)

        #_____________________________________________________________________________________COMPUTE OUT

        dataHandle = dataBlock.outputValue(self.outputTAttr)
        dataHandle.set3Double(translate[0], translate[1], translate[2])
        dataHandle.setClean()

        dataHandle = dataBlock.outputValue(self.outputRAttr)
        dataHandle.set3Double(math.radians(rotate[0]), math.radians(rotate[1]),
                              math.radians(rotate[2]))
        dataHandle.setClean()

        dataHandle = dataBlock.outputValue(self.outputSAttr)
        dataHandle.set3Double(scale[0], scale[1], scale[2])
        dataHandle.setClean()

        dataBlock.setClean(plug)
class Tt_FileBackUp:

    ExFrameLayout = ""
    Tt_windowName = "Tt_FileBackUp"
    In = cmds.playbackOptions(q=True,min=True)
    Out = cmds.playbackOptions(q=True,max=True)
    FilesPath = ""
    OutDirValue = ""
    OutDirButton = ""
    InDirValue = ""

    @classmethod
    def main(self,*args):

        if cmds.window(self.Tt_windowName ,exists=True):
            cmds.deleteUI(self.Tt_windowName ,window=True)

        MainWindow = cmds.window(self.Tt_windowName,t=self.Tt_windowName,w=450,resizeToFitChildren=True)
        cmds.columnLayout()
        self.ExFrameLayout = cmds.frameLayout(l="Export",backgroundColor=[0.8,0.2,0.3],w=450)
        cmds.rowLayout(nc=1)
        cmds.text(l=u"  ■書き出し")
        cmds.setParent("..")

        cmds.rowLayout(nc=3)
        self.OutDirValue = cmds.textField(w=410)
        self.Tt_Path = cmds.workspace(q=True,rootDirectory=True)

        cmds.textField( self.OutDirValue, edit=True,text=self.Tt_Path,enable=False)
        self.OutDirButton = cmds.button(l="...",w=30,enable=False)
        cmds.setParent("..")
        
        cmds.rowLayout(nc=3)
        self.CheckScene = cmds.checkBox(l=u"Sceneファイルも書き出す",v=True)
        self.CheckMemo = cmds.checkBox(l=u"メモファイルも書き出す",v=True,cc=self.ChangeBox)
        self.CheckXGen = cmds.checkBox(l=u"XGenファイルも書き出す",v=True)
        cmds.setParent("..")
        
        cmds.rowLayout(nc=1)
        cmds.text(l=u"  ■メモ (こちらに記載して下さい。)")
        cmds.setParent("..")
        
        cmds.rowLayout(nc=1)
        self.TectBox = cmds.scrollField( editable=True, wordWrap=True, text=u'',h=90,w=440 )
        cmds.setParent("..")
        
        cmds.rowLayout(nc=1)
        cmds.button(l="Export!!",w=440,h=40,backgroundColor=[0.8,0.2,0.3],c=self.BackUPPPPPP)
        cmds.setParent("..")

        cmds.showWindow(MainWindow)
        
    @classmethod
    def ChangeBox(self,*args):
        Valie = cmds.checkBox(self.CheckMemo,q=True,v=True)
        if Valie:
            cmds.scrollField(self.TectBox, e=True,enable=True)
        else:
            cmds.scrollField(self.TectBox, e=True,enable=False)

    @classmethod
    def BackUPPPPPP(self,*args):
        Flag = cmds.checkBox(self.CheckScene,q=True,v=True)
        FlagXgen = cmds.checkBox(self.CheckXGen,q=True,v=True)
        day = datetime.datetime.now()
        Time = day.strftime("%m-%d_%Hh%Mm%Ss")
        Scene_Name = cmds.file( query=True, sn=True).rpartition( "/" )[0] 
        Scene_Name_Only = cmds.file( query=True, sn=True , shn=True).partition( "." )[0]
        Scene_Exten = cmds.file( query=True, sn=True , shn=True).partition( "." )[-1]
            
        Path = Scene_Name + "/versionFolder/"
        if not os.path.exists(Path): 
            os.makedirs(Path)
        Path2 = Path + "/" + Time + "/"
        if not os.path.exists(Path2): 
            os.makedirs(Path2)

        if Flag:
            cmds.file(save=True, force=True)            
            Rename = str(Path2)+str(Scene_Name_Only)+"_"+str(Time)+"."+Scene_Exten
            Scene_Dir = cmds.file( query=True, sn=True)
            shutil.copyfile(Scene_Dir, Rename)
        
        if FlagXgen:
            Scene_Name = cmds.file( query=True, sn=True).rpartition( "/" )[0]
            XGenPath = Scene_Name.rpartition( "/" )[0] + "/xgen/"

            if not os.path.exists(XGenPath): 
                os.makedirs(XGenPath)

            Sel = cmds.ls(sl=True)[0]
            try:
                xg.exportPalette(str(Sel), str(XGenPath) + "Collection.xgen")
            except:
                print "NG"
            RenameXgen = str(Path2)+str(Scene_Name_Only)+"_"+str(Time)+".xgen"
            shutil.copyfile(str(XGenPath) + "Collection.xgen", RenameXgen)
        
        FlagMemo = cmds.checkBox(self.CheckMemo,q=True,v=True)
        if FlagMemo:
            f = open(Path2 + Scene_Name_Only + "_" + Time +".txt",'w')
            textVal = cmds.scrollField(self.TectBox,q=True,text=True)
            WriteText = textVal.splitlines()
            for i in WriteText:
                f.write(i)
                f.write("\r\n")
            f.close()
Example #33
0
import traceback
            for j in export_geo:
                if j in i:
                    needed_meshes.append(i)
                    # print 'Found %s, adding.' % i
        cmds.select(needed_meshes, replace=True)
        cmds.pickWalk(direction='up')

        abc_export_path = os.path.join(shot_root, 'geo', 'anim_export')
        if not os.path.exists(abc_export_path):
            os.mkdir(abc_export_path)

        abc_anim_name = 'anim_export_%s_anim.abc' % char_name
        export_string = ''
        for i in cmds.ls(sl=True, long=True):
            export_string += ' -root %s ' % i
        print '\t\tExporting ABC file...'
        cmd = '-frameRange %d %d' % (frame_s - 61, frame_e + 1)
        cmd += ' -uvWrite -writeColorSets -writeFaceSets -wholeFrameGeo -worldSpace -writeCreases -writeUVSets -stripNamespaces 0 -dataFormat ogawa '
        cmd += export_string
        cmd += ' -file %s' % os.path.join(abc_export_path, abc_anim_name)
        cmds.AbcExport(j=cmd)
    else:
        print 'ERROR! No export_geo.json file for %s.' % char_name

# CLOSE UNDO CHUNK and RESET
cmds.undoInfo(closeChunk=True)
# cmds.undo()
cmds.playbackOptions(minTime=frame_s - 60)
cmds.currentTime(frame_s - 60)
print 'Done with Export.'
Example #35
0
    cmds.spaceLocator(n="{0}_tLoc".format(tObj))
    cmds.scale(30, 30, 30)
    cmds.spaceLocator(n="{0}_pLoc".format(pObj))
    cmds.parent(tLoc, pLoc)
    cmds.parentConstraint(pObj, pLoc, mo=False)
    cmds.parentConstraint(tObj, tLoc, mo=False)

    if (highlight):

        tRange = cmds.timeControl(aPlayBackSliderPython, query=True, rangeArray=True)

        cmds.bakeResults(tLoc, simulation=True, t=(tRange[0], tRange[1]))
        cmds.parentConstraint(tLoc, tObj, mo=False)

    else:
        startTime = cmds.playbackOptions(query=True, minTime=True)
        endTime = cmds.playbackOptions(query=True, maxTime=True)

        cmds.bakeResults(tLoc, simulation=True, t=(startTime, endTime))
        cmds.parentConstraint(tLoc, tObj, mo=False)

# If one object is selected, runs Track and Constrain.
elif len(sel):
    tObj = sel[0]
    tLoc = "{0}_tLoc".format(tObj)

    # Creates Locator, snaps to object, constrains object to Locator.
    cmds.spaceLocator(n="{0}_tLoc".format(tObj))
    cmds.scale(30, 30, 30)
    cmds.parentConstraint(tObj, tLoc, mo=False)
Example #36
0
 def getSliderRange(self, *args):
     """gets framerange in current scene and returns start and end frames"""
     #get timeslider range start
     self.startF = cmds.playbackOptions(query=True, min=True)
     self.endF = cmds.playbackOptions(query=True, max=True)
Example #37
0
 def _maya_set_playback_range(self, start, end):
     cmds.playbackOptions(min=start, max=end)
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)

        #Define the element in this QWidget.
        self.logoLabel = QtGui.QLabel(
            "<font size='12' color='gray'><B>CONVERSION TOOL</B></font>")

        self.FFLabel = QtGui.QLabel('First Frame')
        ff = cmds.playbackOptions(q=True, minTime=True)
        self.FFText = QtGui.QLineEdit()
        self.FFText.setText(str(int(ff)))

        self.LFLabel = QtGui.QLabel('Last Frame')
        lf = cmds.playbackOptions(q=True, maxTime=True)
        self.LFText = QtGui.QLineEdit()
        self.LFText.setText(str(int(lf)))

        self.sourceLabel = QtGui.QLabel('Ground Node')
        self.sourceText = QtGui.QLineEdit()

        self.handleLabel = QtGui.QLabel('Control Node')
        self.handleText = QtGui.QLineEdit()

        self.targetLabel = QtGui.QLabel('Camera Node')
        self.targetText = QtGui.QComboBox()
        string_list = cmds.listCameras()
        try:
            string_list.remove(u'front')
        except:
            pass
        try:
            string_list.remove(u'persp')
        except:
            pass
        try:
            string_list.remove(u'side')
        except:
            pass
        try:
            string_list.remove(u'top')
        except:
            pass
        self.targetText.addItems(string_list)

        self.convertButton = QtGui.QPushButton('Convert')

        self.label = QtGui.QLabel(
            "State:  Input right node then click Convert button,\n            You'll get a new camera named AbsoluteCamera1."
        )
        self.connect(self.convertButton, QtCore.SIGNAL('clicked()'),
                     self.convert)

        #Set the layout of QWidget.
        self.setWindowTitle("CONVERSION TOOL")
        self.resize(400, 300)
        layout = QtGui.QGridLayout()
        layout.setSpacing(10)
        layout.addWidget(self.logoLabel, 1, 1, 2, 2)
        layout.addWidget(self.FFLabel, 3, 1)
        layout.addWidget(self.FFText, 3, 2)
        layout.addWidget(self.LFLabel, 4, 1)
        layout.addWidget(self.LFText, 4, 2)
        layout.addWidget(self.sourceLabel, 5, 1)
        layout.addWidget(self.sourceText, 5, 2)
        layout.addWidget(self.handleLabel, 6, 1)
        layout.addWidget(self.handleText, 6, 2)
        layout.addWidget(self.targetLabel, 7, 1)
        layout.addWidget(self.targetText, 7, 2)
        layout.addWidget(self.label, 8, 1, 8, 2)
        layout.addWidget(self.convertButton, 10, 1, 10, 2)

        self.setLayout(layout)

        PointToWindow = OpenMayaUI.MQtUtil.mainWindow()
        mainWindow = shiboken.wrapInstance(long(PointToWindow), QtGui.QWidget)
        self.setParent(mainWindow, QtCore.Qt.Dialog)
Example #39
0
 def __getSceneStartFrame(self):
     return str(int(mc.playbackOptions(q=True, min=True)))
Example #40
0
            cmds.setKeyframe('Flower' + str(nf),
                             attribute="rotateY",
                             value=(tx / (2 * floating[nf] + 1)),
                             t=tx + (nf * offset))
            cmds.setKeyframe('Flower' + str(nf),
                             attribute="translateX",
                             value=iniposx[nf] -
                             translation[nf] * math.sin(tx / 100.0),
                             t=tx + (nf * offset))
            cmds.setKeyframe('Flower' + str(nf),
                             attribute="translateZ",
                             value=iniposz[nf] -
                             translation[nf] * math.cos(tx / 100.0),
                             t=tx + (nf * offset))
            if (tx == 660):
                floating[nf] = 1
                cmds.setKeyframe('Flower' + str(nf),
                                 attribute="rotateX",
                                 value=0,
                                 t=tx + (nf * offset))
                cmds.setKeyframe('Flower' + str(nf),
                                 attribute="rotateZ",
                                 value=0,
                                 t=tx + (nf * offset))


FLOWERS = 5
cmds.playbackOptions(minTime='0', maxTime=str(750 * FLOWERS))
flowerAnimation(FLOWERS)
cmds.play
Example #41
0
def frame_range():
    return int(mc.playbackOptions(q=True, min=True)), int(
        mc.playbackOptions(q=True, max=True))
Example #42
0
 def __getSceneEndFrame(self):
     return str(int(mc.playbackOptions(q=True, max=True)))
Example #43
0
def inTime(newTime=None):
    if newTime != None and newTime != 0:
        mc.playbackOptions(minTime=newTime, animationStartTime=newTime)
    elif newTime != None and newTime == 0:
        mc.playbackOptions(minTime=newTime, animationStartTime=newTime)
    return int(mc.playbackOptions(q=True, animationStartTime=True))
Example #44
0
def bakeall():
    amintime = cmds.playbackOptions(query=1, minTime=1)
    amaxtime = cmds.playbackOptions(query=1, maxTime=1)
    listtobake = selectallcontrols()
    cmds.bakeSimulation(listtobake, t=(amintime, amaxtime))