Beispiel #1
0
        def scubValueChangedCmd(value, self=self):
            """commands to run when the value of the slider has changed"""
            try:
                #print value

                # get stepped value if SHIFT modifier is down
                modifiers = QtGui.QApplication.keyboardModifiers()
                if modifiers == QtCore.Qt.ShiftModifier:
                    value = self.getSteppedValue(value, self.shiftStep)
                    print 'shift down'
                # update internal variables
                self.previousValue = value
                self.currentValues[self.currentValueIndex]  = value

                # update the marker lines in the graph widget if it is visible
                if self.isVisible():
                    self.graphWidget.setTimeMarker(self.currentValueIndex, value)

                # run the change command with the given value
                if changeCommand is not None:
                    values = list(self.currentValues)
                    values.sort()
                    self.changeCommand(self, values)

            except:
                ka_python.printError()
                self.finish()
Beispiel #2
0
    def attrShortName(self):

        # Quick Query
        propertyValue = self._getProperty(
            'attrShortName',
            checkDataBase=True,
        )
        if propertyValue != None:
            return propertyValue

        # Regular Query
        try:
            self._attrShortName = self.attr().name(includeNode=False,
                                                   longName=False,
                                                   fullAttrPath=False,
                                                   placeHolderIndices=False)
            self._addToDataBase('attrShortName', self._attrShortName)
            return self._attrShortName

        except:
            ka_python.printError()

        # Alternative Value
        self._attrShortName = self._attrName
        return self._attrShortName
Beispiel #3
0
    def attrLongName(self):
        """the attrLong name is important because it is used as a key in the dataBase.
        It therfore cannot be stored in the database"""

        # Quick Query
        propertyValue = self._getProperty(
            'attrLongName')  # can not check DB, as it is used as key
        if propertyValue != None:
            return propertyValue

        # Regular Query
        try:
            self._attrLongName = self.node().attr(self.attrName()).name(
                includeNode=False,
                longName=True,
                fullAttrPath=True,
                placeHolderIndices=True)
            return self._attrLongName

        except:
            ka_python.printError()

        # Alternative Value
        self._attrLongName = self.attrName()
        return self._attrLongName
Beispiel #4
0
def getCurrentPannel():
    try:
        panel = pymel.getPanel(underPointer=True)
        panel = panel.split('|')[-1]
        return panel

    except:
        ka_python.printError()
        print '## Failed to find current panel, make sure you have a view port with focus'
Beispiel #5
0
def startStrandBlend():
    global weightBlenderInfo

    weightBlenderInfo = WeightBlenderInfo()
    try:
        weightBlenderInfo.startStrandBlend()
    except:
        ka_python.printError()
        finish()
Beispiel #6
0
def change(*args, **kwargs):
    global weightBlenderInfo

    try:
        if weightBlenderInfo:
            weightBlenderInfo.blend(*args, **kwargs)
        else:
            print 'weightBlender does not exist'

    except:
        ka_python.printError()
        finish()
Beispiel #7
0
    def attr(self):
        # Quick Query
        propertyValue = self._getProperty('attr')
        if propertyValue != None:
            return propertyValue

        try:
            self._attr = self.node().attr(self.attrLongName())
            return self._attr

        except:
            ka_python.printError()
Beispiel #8
0
    def nodeLongName(self, refresh=False):
        # Quick Query
        if not refresh:
            propertyValue = self._getProperty('nodeLongName')
            if propertyValue != None:
                return propertyValue

        try:
            return self._node.name(long=True)

        except:
            ka_python.printError()
            return self.nodeName()
Beispiel #9
0
    def nodeTypes(self):
        # Quick Query
        propertyValue = self._getProperty('nodeTypes')
        if propertyValue != None:
            return propertyValue

        # Regular Query
        try:
            self._nodeTypes = self.node().nodeType(inherited=True)
            return self._nodeTypes

        except:
            ka_python.printError()
Beispiel #10
0
    def nodeType(self):
        # Quick Query
        propertyValue = self._getProperty('nodeType')
        if propertyValue != None:
            return propertyValue

        # Regular Query
        try:
            self._nodeType = self.node().nodeType()
            return self._nodeType

        except:
            ka_python.printError()
Beispiel #11
0
def createScrubSlider(*args, **kwargs):
    """Returns scrubSlider. This is the main function to create the scrub slider"""
    print 'make'
    scrubSlider = getScrubSlider()
    if scrubSlider:
        try:
            scrubSlider.finish()
        except:
            ka_python.printError()

    else:
        scrubSlider = ScrubWidget(*args, **kwargs)
        scrubSlider.setObjectName('scrubSlider')

    return scrubSlider
Beispiel #12
0
def tryToXform(*args, **kwargs):

    try:
        if args[0] != None:
            if 'mirrorTransform' in kwargs:
                mirrorTransform = kwargs.pop('mirrorTransform')
            else:
                mirrorTransform = None

            pymel.xform(*args, **kwargs)

            if mirrorTransform:
                ka_transforms.mirrorTransform(mirrorTransform,
                                              targetTransform=args[0])

    except:
        ka_python.printError()
Beispiel #13
0
#get the folder that represents the current version
currentVersionFolder = []
for folder in subfolders:
    if str(folder) in version:
        currentVersionFolder.append(
            cleanPath(os.path.join(currentDirectory, folder)))

#make sure that there is only 1 folder for current version
if not len(currentVersionFolder) == 1:
    if len(currentVersionFolder) == 0:
        print '!! Warning no version folder found for current version of maya in ka_maya/ka_mayaCommandOverrides'
    else:
        print '!! Warning too many version folders found for current version of maya in ka_maya/ka_mayaCommandOverrides'

else:
    #get list of file which are .mel
    melScriptFiles = []
    for file in os.listdir(currentVersionFolder[0]):
        if file[-4:] == '.mel':
            melScriptFiles.append(
                cleanPath(os.path.join(currentVersionFolder[0], file)))

    #and finally source them
    for filePath in melScriptFiles:
        try:
            mel.eval('source "' + filePath + '"')

        except:
            print "FAILED TO LOAD MEL FILE: %s" % filePath
            ka_python.printError()
def importDeformers(listOfPaths, **kwargs):
    """main call, it exports the given nodes, or if none given will export selected objects
    arg[0:-1] - nodes to export
    arg[-1]   - path to export to
    """
    pathDict = {}
    for path in listOfPaths:
        baseName = os.path.basename(path)
        pathDict[baseName] = path

    inclusionList = kwargs.get('inclusionList', [])

    allDeformerPackages = []
    allDeformationOrderFiles = []
    deformerPath_dictionary = {}

    for path in listOfPaths:

        if path.endswith(DEFORMER_ORDER_SUFFIX):
            allDeformationOrderFiles.append(path)

        #if eachFilePath.endswith(DEFORMER_SUFFIX):
        elif os.path.isdir(path):
            allDeformerPackages.append(path)

            # the keys of this dictionary are the deformer names, and the values
            # are the true file paths. This allows file lists with files from various
            # directorys to be passed in. This should be queried when opening a deformer file
            deformerName = os.path.basename(path)
            #eachDeformerName = eachFileName.split(DEFORMER_SUFFIX)[0]
            deformerPath_dictionary[deformerName] = path



    listOf_deformedObjectsInfo = []
    listOf_deformedObjectsInfo_toLoad = []
    for deformationOrderFilePath in allDeformationOrderFiles:
        deformationOrderFileName = os.path.basename(deformationOrderFilePath)
        #deformerDirectory = os.path.split(eachFilePath)[0]

        with open(deformationOrderFilePath, 'r') as f:
            dataString = f.read()
            deformationOrder = ast.literal_eval(dataString)


        # prune tweaks and other unspecified deformers and populate a list of tuples
        # where item 1 is a deformer and item 2 is a list of objects that deformer deforms
        prunedDeformationOrderPairs = []
        for deformer in deformationOrder:
            # does deformer have a deformer file in the deformer file dictionary?
            if deformer in deformerPath_dictionary:
                deformerPath = deformerPath_dictionary[deformer]

                if deformerPath in allDeformerPackages:
                    with open(os.path.join(deformerPath, 'kwargs.py'), 'r') as f:
                        dataString = f.read()
                        deformerKwargs = ast.literal_eval(dataString)
                    deformedObjects = deformerKwargs['deformedNodes']
                    prunedDeformationOrderPairs.append((deformer, deformedObjects))

        shape = deformationOrderFileName.split(DEFORMER_ORDER_SUFFIX)[0]
        dataPair = [shape, prunedDeformationOrderPairs]

        # the inclusion list if for loading a selected few deformers
        if inclusionList:
            if shape in inclusionList:
                listOf_deformedObjectsInfo_toLoad.append(tuple(dataPair))

        else:
            listOf_deformedObjectsInfo_toLoad.append(tuple(dataPair))

        listOf_deformedObjectsInfo.append(tuple(dataPair))

    OOOOOOO = "listOf_deformedObjectsInfo_toLoad"; print '%s: ' % OOOOOOO, eval(OOOOOOO), ' ', type(eval(OOOOOOO))
    cA = 0
    # WHILE THERE ARE MESHS TO LOAD DEFORMERS ON
    while listOf_deformedObjectsInfo_toLoad:
        cA += 1
        if cA > 9999:
            pymel.error('while loop A max limit hit')
            break


        deformedObjectInfo = listOf_deformedObjectsInfo_toLoad[0]
        deformedObject, listOf_deformersAndDeformedObjects = deformedObjectInfo
        if log:print '~',
        if log:print deformedObject

        cB = 0
        #WHILE THERE ARE DEFORMERS TO LOAD
        while listOf_deformersAndDeformedObjects:
            cB += 1
            if cB > 9999:
                pymel.error('while loop B  max limit hit')
                break


            deformerAndDeformedObjects = listOf_deformersAndDeformedObjects[0]
            deformer, deformedObjects = deformerAndDeformedObjects
            if log:print '    deformer:',
            if log:print deformer

            deformerPackage = deformerPath_dictionary[deformer]

            #CAN WE LOAD? CHECK HERE
            unloadableFlag = False
            for deformedObject in deformedObjects:
                if inclusionList:
                    if deformedObject not in inclusionList:
                        unloadableFlag = True

            if unloadableFlag:
                if log:print '        %s will never be ready to load because it deformes objects that are not in the selection' % deformer
                break

            if isDeformerReadyToLoad(deformer, listOf_deformedObjectsInfo):

                listOf_deformersAndDeformedObjects.pop(0)

                try:
                    importDeformer(deformerPackage, **kwargs)

                except:
                    ka_python.printError()
                    print '            failed to load deformer because of a code error (seek help) %s' % deformer

            else:
                listOf_deformersAndDeformedObjects.append(listOf_deformersAndDeformedObjects.pop(0))
                break

        listOf_deformedObjectsInfo_toLoad.pop(0)