示例#1
0
def ATT_INCREMENT(iAmount):
    # Attribute Increment v3.0.0
    oChannel = [
        str(c + '.' + cmds.attributeName(c + '.' + b, l=True)) for a in 'msho'
        for b in cmds.channelBox('mainChannelBox', **{
            'q': True,
            's%sa' % a: True
        }) or [] for c in cmds.channelBox(
            'mainChannelBox', q=True, **{'%sol' % a: True})
    ]

    if oChannel:
        for c in oChannel:
            iVal = cmds.getAttr(c)
            cmds.setAttr(c, iVal + iAmount)

        if iAmount >= 0.01:
            aPrint = ['a7a8af', '+' + str(iAmount), 0x6b6c75, 'botCenter']
        else:
            aPrint = ['d8766c', '+' + str(iAmount), 0x756b6b, 'botCenter']
    else:
        aPrint = ['d8766c', 'No Attr Selected', 0x756b6b, 'topCenter']

    cmds.inViewMessage(amg='<text style="color:#%s";>%s</text>' %
                       (aPrint[0], aPrint[1]),
                       pos=aPrint[3],
                       fade=True,
                       fts=10,
                       ft='arial',
                       bkc=aPrint[2])
示例#2
0
def get_channelbox_attributes():
    """
    Get the short names of attributes selected in the channel box.
    
    :return: Set of attributes short name as strings or None
    :rtype: set of string or None
    """

    attr = set()

    s1 = cmds.channelBox('mainChannelBox', q=True, selectedMainAttributes=True)
    s2 = cmds.channelBox('mainChannelBox',
                         q=True,
                         selectedShapeAttributes=True)
    s3 = cmds.channelBox('mainChannelBox',
                         q=True,
                         selectedHistoryAttributes=True)
    s4 = cmds.channelBox('mainChannelBox',
                         q=True,
                         selectedOutputAttributes=True)

    if s1:
        attr |= set(s1)
    if s2:
        attr |= set(s2)
    if s3:
        attr |= set(s3)
    if s4:
        attr |= set(s4)

    if len(attr) == 0:
        return None

    return attr
示例#3
0
	def guiInfo(self):
		radioChoice = cmds.radioButtonGrp( self.rbtn, q=True, sl=True)
		txt = cmds.textFieldGrp( self.txt, q=True, tx=True)
		
		if( radioChoice == 1 ):  # ChannelBox
			sma = cmds.channelBox("mainChannelBox", q=True, sma=True)
			ssa = cmds.channelBox("mainChannelBox", q=True, selectedShapeAttributes=True)
			sha = cmds.channelBox("mainChannelBox", q=True, selectedHistoryAttributes=True)
			selected = cmds.ls(sl=True)
			
			allAttrs = []
			if( sma ):
				allAttrs.extend(sma)
			if( ssa ):
				allAttrs.extend(ssa)
			if( sha ):
				allAttrs.extend(sha)

			curAttrs = []
			for sel in selected:
				for attr in allAttrs:
					curAttrs.append( "%s.%s" %(sel, attr))
			
			self.addAttrs( curAttrs )
		else:
			self.addAttr( txt )
示例#4
0
    def updateSearch(self, matchString, nodes):
        """
        Loop over all keyable attributes and match them with the search string.
        
        :param str matchString: Search string to match with attributes
        :param list nodes: List of nodes to process the attributes from
        """
        # reset of search string is empty
        if not matchString:
            cmds.channelBox(CHANNELBOX, edit=True, fixedAttrList=[])
            return

        # split match string
        matches = []
        matchStrings = matchString.lower().split()

        # get matching attributes
        for node in nodes:
            attrs = cmds.listAttr(node, k=True, v=True)

            for attr in attrs:
                if (not attr in matches
                        and self.matchSearch(attr, matchStrings)):
                    matches.append(attr)

        # append null if not matches are found ( cannot use empty list )
        if not matches:
            matches.append("null")

        # filter channel box
        cmds.channelBox(CHANNELBOX, edit=True, fixedAttrList=matches)
示例#5
0
def get_channelbox():
    return [
        c + "." + b for a in "msho" for b in
        cmds.channelBox("mainChannelBox", q=True, **{"s%sa" % a: True}) or []
        for c in cmds.channelBox(
            "mainChannelBox", q=True, **{"%sol" % a: True})
    ]
示例#6
0
def getSelectedChannels():
    """
    Returns selected attributes in the channel box.
    Queries the main, the shape and the input attrs.
    
    Returns list of selected channels.
    """
    channel_box = mel.eval(
        'global string $gChannelBoxName; $temp=$gChannelBoxName;'
    )  #fetch maya's main channelbox
    selectedAttrs = []

    shapeAttrs = cmds.channelBox(channel_box,
                                 q=True,
                                 selectedShapeAttributes=True)
    mainAttrs = cmds.channelBox(channel_box,
                                q=True,
                                selectedMainAttributes=True)
    inputAttrs = cmds.channelBox(channel_box,
                                 q=True,
                                 selectedHistoryAttributes=True)

    if shapeAttrs:
        selectedAttrs.extend(shapeAttrs)

    if mainAttrs:
        selectedAttrs.extend(mainAttrs)

    if inputAttrs:
        selectedAttrs.extend(inputAttrs)

    return selectedAttrs
示例#7
0
 def change_speed(self, direction=0):
     self.speed_index += direction
     if not direction:
         self.speed_index = 0
     self.speed = pow(2, self.speed_index)
     cmds.button(self.speed_reset_btn, e=True, label=round(self.speed, 10))
     cmds.channelBox(self.c_box, e=True, speed=self.speed)
     return
示例#8
0
 def hyperbolicSet(self, *args):
     hyperbolicCheck = cmds.menuItem('hyperCheckBox',
                                     query=True,
                                     checkBox=True)
     if hyperbolicCheck == True:
         cmds.channelBox('Channel Box', e=True, hyp=True)
     if hyperbolicCheck == False:
         cmds.channelBox('Channel Box', e=True, hyp=False)
示例#9
0
    def updateColour(self, nodes):
        """
        Loop over the selected objects user defined attributes, and generate 
        a colour for them, nodeRegex is not used because it slows down the 
        displaying of the the Channel Box in scenes with many user defined 
        attributes. 
        
        :param list nodes: list of selected nodes
        """
        for node in nodes:
            # get user defined attributes
            attrs = cmds.listAttr(node, userDefined=True) or []

            # set default colour indices
            mainColour, subColour = 0, 0

            # loop attributes
            for i, attr in enumerate(attrs):
                # get attribute state
                isLocked = cmds.getAttr("{0}.{1}".format(node, attr), l=True)
                isKeyable = cmds.getAttr("{0}.{1}".format(node, attr), k=True)

                # catch divider
                if isLocked or not isKeyable:
                    # update colour indices
                    mainColour += 1
                    subColour = 0

                    if mainColour == len(USER_COLOURS):
                        mainColour = 0

                    # update colour
                    cmds.channelBox(CHANNELBOX,
                                    edit=True,
                                    attrRegex=attr,
                                    attrBgColor=DIVIDER_COLOUR)

                    continue

                # match string with previous attribute to get sub colour
                if i != 0:
                    # get match ratio
                    ratio = difflib.SequenceMatcher(None, attr,
                                                    attrs[i - 1]).ratio()

                    # compare match ratio with threshold
                    if ratio < self.threshold:
                        subColour += 1

                        if subColour == len(USER_COLOURS[mainColour]):
                            subColour = 0

                # update colour
                colour = USER_COLOURS[mainColour][subColour]
                cmds.channelBox(CHANNELBOX,
                                edit=True,
                                attrRegex=attr,
                                attrBgColor=colour)
示例#10
0
    def ShiftAtt(mode,
                 _obj=mc.channelBox('mainChannelBox', q=True, mol=True),
                 _attr=mc.channelBox('mainChannelBox', q=True, sma=True)):
        """
        Shift an attribute in the channelBox
        @param mode: {0:1}
            if 0: shift Down
            if 1: shift Up
        """
        obj = _obj
        if obj:
            attr = _attr
            if attr:
                for eachObj in obj:
                    udAttr = mc.listAttr(eachObj, ud=True)
                    if not attr[0] in udAttr:
                        sys.exit(
                            'selected attribute is static and cannot be shifted'
                        )
                    # temp unlock all user defined attributes
                    attrLock = mc.listAttr(eachObj, ud=True, l=True)
                    if attrLock:
                        for alck in attrLock:
                            mc.setAttr(eachObj + '.' + alck, lock=0)

                    # shift down
                    if mode == 0:
                        if len(attr) > 1:
                            attr.reverse()
                            sort = attr
                        if len(attr) == 1:
                            sort = attr
                        for i in sort:
                            attrLs = mc.listAttr(eachObj, ud=True)
                            attrSize = len(attrLs)
                            attrPos = attrLs.index(i)
                            mc.deleteAttr(eachObj, at=attrLs[attrPos])
                            mc.undo()
                            for x in range(attrPos + 2, attrSize, 1):
                                mc.deleteAttr(eachObj, at=attrLs[x])
                                mc.undo()
                    # shift up
                    if mode == 1:
                        for i in attr:
                            attrLs = mc.listAttr(eachObj, ud=True)
                            attrSize = len(attrLs)
                            attrPos = attrLs.index(i)
                            if attrLs[attrPos - 1]:
                                mc.deleteAttr(eachObj, at=attrLs[attrPos - 1])
                                mc.undo()
                            for x in range(attrPos + 1, attrSize, 1):
                                mc.deleteAttr(eachObj, at=attrLs[x])
                                mc.undo()

                    # relock all user defined attributes
                    if attrLock:
                        for alck in attrLock:
                            mc.setAttr(eachObj + '.' + alck, lock=1)
示例#11
0
def unselectChannelBox():
    currList = cmds.channelBox('mainChannelBox',
                               query=True,
                               fixedAttrList=True)
    cmds.channelBox('mainChannelBox', edit=True, fixedAttrList=[""])

    function = lambda *args: cmds.channelBox(
        'mainChannelBox', edit=True, fixedAttrList=currList)
    G.deferredManager.sendToQueue(function, 1, "unselectChannelBox")
示例#12
0
 def on_btn_inputBsattr_clicked(self, args=None):
     if args == None: return
     blendShape = mc.ls(sl=True, type='blendShape')
     if len(mc.ls(sl=True)) == 1:
         attrs = mc.channelBox('mainChannelBox', q=True, sma=True)
     else:
         attrs = mc.channelBox('mainChannelBox', q=True, sha=True)
     if not attrs: return
     self.lineEdit.setText('%s.%s' % (blendShape[0], attrs[0]))
示例#13
0
def get_selectedFromChannelBox(attributesOnly=False):
    """ 
    Returns a list of selected object attributes from the channel box
    
    :parameters:
        attributesOnly(bool): Whether you want
        
    Keyword arguments:
    returnRaw() -- whether you just want channels or objects combined with selected attributes

    """
    _str_func = 'get_selectedFromChannelBox'
    _sel = mc.ls(sl=True)
    ChannelBoxName = mel.eval('$tmp = $gChannelBoxName')

    sma = mc.channelBox(ChannelBoxName, query=True, sma=True)
    ssa = mc.channelBox(ChannelBoxName, query=True, ssa=True)
    sha = mc.channelBox(ChannelBoxName, query=True, sha=True)
    soa = mc.channelBox(ChannelBoxName, query=True, soa=True)

    channels = []
    if sma:
        log.debug(cgmGEN.logString_msg(_str_func, "sma: {0}".format(sma)))
        channels.extend(sma)
    if ssa:
        log.debug(cgmGEN.logString_msg(_str_func, "ssa: {0}".format(sma)))
        channels.extend(ssa)
    if sha:
        log.debug(cgmGEN.logString_msg(_str_func, "sha: {0}".format(sha)))
        channels.extend(sha)
    if soa:
        log.debug(cgmGEN.logString_msg(_str_func, "soa: {0}".format(soa)))
        channels.extend(soa)

    if channels and _sel:
        _channels_long = []
        for c in channels:
            _channels_long.append(c)
            """
            _l = ATTR.get_nameLong(_sel[0],c)
            if '.weight' not in _l:
                _channels_long.append(_l)
            else:
                _channels_long.append(c)"""

        if attributesOnly:
            return _channels_long
        else:
            _res = []
            for item in _sel:
                for attr in _channels_long:
                    _comb = "{0}.{1}".format(item, attr)
                    if mc.objExists(_comb):
                        _res.append(_comb)
            return _res
    return False
示例#14
0
 def on_add_btn_clicked(self):
     
     selNodes = cmds.ls(sl=1, ap=1)
     if not selNodes:
         om.MGlobal.displayError("Please select some nodes and attributes.")
         return
     
     selAttrs = (cmds.channelBox("mainChannelBox", q=1, sma=1) or []) \
         + (cmds.channelBox("mainChannelBox", q=1, sha=1) or []) \
         + (cmds.channelBox("mainChannelBox", q=1, ssa=1) or []) \
         + (cmds.channelBox("mainChannelBox", q=1, soa=1) or [])
     
     if not selAttrs:
         selAttrs = cmds.listAttr(selNodes, v=1, k=1, sn=1)
         selAttrs = list(set(selAttrs))
         try:
             selAttrs.remove('v')
         except:
             pass
     
     self.table.clearSelection()
     
     for node in selNodes:
         for attr in selAttrs:
             name = "%s.%s" % (node, attr)
             minVal, maxVal = 0.0, 1.0
             hasMinVal, hasMaxVal = False, False
             
             if not cmds.objExists(name):
                 continue
             
             # Set minVal
             if cmds.attributeQuery(attr, node=node, minExists=1):
                 minVal = cmds.attributeQuery(attr, node=node, min=1)[0]
                 hasMinVal = True
             
             if cmds.attributeQuery(attr, node=node, softMinExists=1):
                 minVal = cmds.attributeQuery(attr, node=node, smn=1)[0]
                 hasMinVal = True
             
             # Set maxVal    
             if cmds.attributeQuery(attr, node=node, maxExists=1):
                 maxVal = cmds.attributeQuery(attr, node=node, max=1)[0]
                 hasMaxVal = True
             
             if cmds.attributeQuery(attr, node=node, softMaxExists=1):
                 maxVal = cmds.attributeQuery(attr, node=node, smx=1)[0]
                 hasMaxVal = True
             
             currVal = cmds.getAttr(name)
             if hasMinVal: minVal = minVal - currVal
             if hasMaxVal: maxVal = maxVal - currVal
                 
             self.appendRow()
             self.setRow(self.numRow()-1, [name, minVal, maxVal])
示例#15
0
def gui():
	'''
	Main GUI procedure for the keyframing script.
	'''
	
	# Check to see if the window already exists
	if( cmds.window(win, q=True, ex=True) ):
		cmds.deleteUI(win)
		
	# main window
	cmds.window(win, title="Keyframing Script", mb=True, w=winWidth, h=winHeight)
	
	cmds.menu(label="File")
	cmds.menuItem(label="Open List",
		c=scriptName + ".readAttr()")
	cmds.menuItem( divider=True)
	cmds.menuItem(label="Save All",
		c=scriptName + ".writeAttrFile()")
	cmds.menuItem(label="Save Sel",
		c=scriptName + ".writeSelAttrFile()")
	
	cmds.menu(label="Shelf Button")
	cmds.menuItem(label="All Attrs",
		c=scriptName + ".allToShelf()")
	cmds.menuItem(label="Sel Attrs",
		c=scriptName + ".selToShelf()")
	cmds.menuItem(label="From File",
		c=scriptName + ".shelfFromFile()")
	
	cmds.menu(label="Scripts")
	cmds.menuItem(label="sbaRename",
		c="import sbaRename; sbaRename.gui()")
	cmds.menuItem(label="sbaRename help",
		c="help(sbaRename)")
	cmds.menuItem( divider=True)
	cmds.menuItem(label="sbaAttr",
		c="import sbaAttr; sbaAttr.gui()")
	cmds.menuItem(label="sbaAttr help",
		c="help(sbaAttr)")
	
	cmds.menu(label="Info")
	cmds.menuItem(label="Help",
		c="help("+scriptName+")")
	cmds.menuItem(label="About")
	# Main Layout
	mainCol = cmds.columnLayout("sbaKeyMC")

	mainRow = cmds.rowColumnLayout(nc=3, cw=[[1,200],[2,30],[3,200]],
		columnOffset=[2,"both",5])
	mainGUI(mainRow)
	cmds.button(label=">>")
	cmds.channelBox('sbaKeyCB')
	
	cmds.showWindow(win)
示例#16
0
def getChannelAttributeFromSelection():

    sma = cmds.channelBox('mainChannelBox', q=1, sma=1)
    ssa = cmds.channelBox('mainChannelBox', q=1, ssa=1)
    sha = cmds.channelBox('mainChannelBox', q=1, sha=1)

    attrs = []
    if sma: attrs += sma
    if ssa: attrs += ssa
    if sha: attrs += sha

    return attrs
示例#17
0
def setChannelBoxAtTop(channelBox, value):
    """
    :param channelBox: mainChannelBox
    :type channelBox: str
    :param value:
    :type value: bool

    .. code-block:: python

        setChannelBoxAtTop("mainChannelBox",True)
    """
    cmds.channelBox(channelBox, edit=True, containerAtTop=value)
示例#18
0
def setChannelShowType(channelBox, value):
    """
    :param channelBox: mainChannelBox
    :type channelBox: str
    :param value:
    :type value: str

    .. code-block:: python

        setChannelShowType("mainChannelBox", "all")
    """
    cmds.optionVar(stringValue=("cbShowType", value))
    cmds.channelBox(channelBox, edit=True, update=True)
示例#19
0
 def setPreNum(self, *args):
     newPreNum = cmds.intField('precisionNumber', query=True, value=True)
     if newPreNum <= 3:
         newWidth = 65
     elif newPreNum <= 6:
         newWidth = 95
     elif newPreNum <= 9:
         newWidth = 115
     elif newPreNum <= 12:
         newWidth = 130
     else:
         newWidth = 155
     cmds.channelBox('Channel Box', edit=True, pre=newPreNum, fieldWidth=newWidth)
     cmds.deleteUI('setPrecisionNumber')
示例#20
0
def HotKey_BreakConnections():
    # Break Connection of Selected Attributes v3.0.0
    oChannel = [
        str(c + '.' + cmds.attributeName(c + '.' + b, l=True)) for a in 'msho'
        for b in cmds.channelBox('mainChannelBox', **{
            'q': True,
            's%sa' % a: True
        }) or [] for c in cmds.channelBox(
            'mainChannelBox', q=True, **{'%sol' % a: True})
    ]

    for c in oChannel:
        aObj = c.split('.')
        cmds.delete(aObj[0], at=aObj[1], c=True)
示例#21
0
def shiftAttr(mode, *args):
    """shifts the selected attr up or down"""

    obj = cmds.channelBox('mainChannelBox', q=True, mol=True)
    if obj:
        attr = cmds.channelBox('mainChannelBox', q=True, sma=True)
        if attr:
            for eachObj in obj:
                udAttr = cmds.listAttr(eachObj, ud=True)
                if not attr[0] in udAttr:
                    sys.exit(
                        'selected attribute is static and cannot be shifted')
                #temp unlock all user defined attributes
                attrLock = cmds.listAttr(eachObj, ud=True, l=True)
                if attrLock:
                    for alck in attrLock:
                        cmds.setAttr(eachObj + '.' + alck, lock=0)
                #shift down
                if mode == 0:
                    if len(attr) > 1:
                        attr.reverse()
                        sort = attr
                    if len(attr) == 1:
                        sort = attr
                    for i in sort:
                        attrLs = cmds.listAttr(eachObj, ud=True)
                        attrSize = len(attrLs)
                        attrPos = attrLs.index(i)
                        cmds.deleteAttr(eachObj, at=attrLs[attrPos])
                        cmds.undo()
                        for x in range(attrPos + 2, attrSize, 1):
                            cmds.deleteAttr(eachObj, at=attrLs[x])
                            cmds.undo()
                #shift up
                if mode == 1:
                    for i in attr:
                        attrLs = cmds.listAttr(eachObj, ud=True)
                        attrSize = len(attrLs)
                        attrPos = attrLs.index(i)
                        if attrLs[attrPos - 1]:
                            cmds.deleteAttr(eachObj, at=attrLs[attrPos - 1])
                            cmds.undo()
                        for x in range(attrPos + 1, attrSize, 1):
                            cmds.deleteAttr(eachObj, at=attrLs[x])
                            cmds.undo()
                #relock all user defined attributes
                if attrLock:
                    for alck in attrLock:
                        cmds.setAttr(eachObj + '.' + alck, lock=1)
示例#22
0
def toggle_channels(channels):
    '''
    You could pass a list such as ['tx', 'ty', 'tz']
    Or a boolean of False to deselect the channels
    '''
    if channels == False:
        cmds.channelBox(CHANNELBOX, edit=True, select=False, update=True)
        mel.eval('syncChannelBoxFcurveEd') # For 2018
        return
    if not isinstance(channels, list): channels = [channels]
    valid_channels = [c for c in channels if c in VALID_ATTRS]
    nodes = cmds.ls(selection=True)
    channels_to_select = ['{}.{}'.format(n, c) for c in valid_channels for n in nodes]
    cmds.channelBox(CHANNELBOX, edit=True, select=channels_to_select, update=True)
    mel.eval('syncChannelBoxFcurveEd') # For 2018
示例#23
0
 def performAttrRetarget(s, old, element1):
     selection = cmds.ls(sl=True, type="transform")
     if len(selection) == 1:
         sel = selection[0]
         # Get attributes selected!
         attr = [
             cmds.attributeQuery(at, n=sel, ln=True)
             for at in cmds.channelBox('mainChannelBox', sma=True, q=True)
         ]
         if len(attr) == 1:
             at = attr[0]
             if at not in s.allItems:
                 # ASK TO CONFIRM FIRST!!
                 ans = cmds.confirmDialog(
                     t=s.i18n["characterRetarget.confirm"],
                     m=s.i18n["characterRetarget.targetConfirm"],
                     button=[s.i18n["yes"], s.i18n["no"]],
                     defaultButton=s.i18n["yes"],
                     cancelButton=s.i18n["no"],
                     dismissString=s.i18n["no"])
                 if ans == s.i18n["yes"]:  # Are we ok to retarget??
                     print "Retargeting %s to %s" % (old, at)
                     s.sendRetarget(s.char, old, at)
                     cmds.button(element1, e=True, l=at)
                     return
             else:
                 raise RuntimeError, "The selected Attribute is already assigned."
     raise RuntimeError, "You must select a single attribute."
示例#24
0
    def connectCommand(uiInstance):

        sels = cmds.ls(sl=1)
        selChannels = cmds.channelBox('mainChannelBox', q=1, sma=1)

        numItems = uiInstance.layout.count()
        animNode = cmds.createNode('animCurveUU')

        for i in range(1, numItems - 1):
            targetWidget = uiInstance.layout.itemAt(i).widget()

            key = targetWidget.lineEdit_key.text()
            value = targetWidget.lineEdit_value.text()

            cmds.setKeyframe(animNode, f=float(key), v=float(value))
            cmds.keyTangent(animNode,
                            f=(float(key), float(key)),
                            itt='linear',
                            ott='linear')

        if sels and selChannels:
            cmds.connectAttr(sels[0] + '.' + selChannels[0],
                             animNode + '.input')
            addString = ''
            if float(key) > 0:
                addString = 'positive'
            else:
                addString = 'negative'
            animNode = cmds.rename(
                animNode,
                selChannels[0] + '_' + addString + '_from_' + sels[0])

        cmds.select(animNode)
示例#25
0
    def __init__(self):
        self.data = {}
        self.nodeList = cmds.ls(sl=True)
        cb = mel.eval(
            'global string $gChannelBoxName; $temp=$gChannelBoxName;')

        self.attrList = cmds.channelBox(cb, q=True, sma=True)
示例#26
0
 def copyAttr(self, sourceItem=False, attrList=False, verbose=False, *args):
     """ Get and store in a dictionary the attributes from sourceItem.
         Returns the dictionary with attribute values.
     """
     # getting sourceItem:
     if not sourceItem:
         selList = cmds.ls(selection=True, long=True)
         if selList:
             sourceItem = selList[0]
         else:
             print self.dpUIinst.langDic[self.dpUIinst.langName]["e015_selectToCopyAttr"]
     if cmds.objExists(sourceItem):
         if not attrList:
             # getting channelBox selected attributes:
             currentAttrList = cmds.channelBox('mainChannelBox', query=True, selectedMainAttributes=True)
             if not currentAttrList:
                 # list all attributes if nothing is selected:
                 currentAttrList = cmds.listAttr(sourceItem, visible=True, keyable=True)
             attrList = currentAttrList
         if attrList:
             # store attribute values in a dic:
             self.attrValueDic = {}
             for attr in attrList:
                 if cmds.objExists(sourceItem+'.'+attr):
                     value = cmds.getAttr(sourceItem+'.'+attr)
                     self.attrValueDic[attr] = value
             if verbose:
                 print self.dpUIinst.langDic[self.dpUIinst.langName]["i125_copiedAttr"]
     return self.attrValueDic
示例#27
0
def loadSel(nameFld, attrFld):
    '''
	Function that loads selected objects or attributes into the driver textFields
	'''

    try:  # run code, but catch errors

        # list first selected item into variable
        selItem = cmds.ls(sl=True)

        # list first selected attribute into variable
        selAttr = cmds.channelBox('mainChannelBox', q=True, sma=True)

        # edit the Driver name textField with first selection
        #cmds.textField( 'drvrNameFld', e=True, tx=selItem[0] )
        cmds.textField(nameFld, e=True, tx=selItem[0])

        # edit the Driver attr textField with first selection
        #cmds.textField( 'drvrAttrFld', e=True, tx=selAttr[0] )
        cmds.textField(attrFld, e=True, tx=selAttr[0])

    except IndexError:  # nothing is selected

        OpenMaya.MGlobal.displayWarning(
            "Please select an object then attribute from the channel box.")

    except TypeError:  # no attr is selected

        OpenMaya.MGlobal.displayWarning(
            "Please select an attribute from the channel box.")
示例#28
0
def addAttrTSL():
	'''
	Add the selected attributes from the channelBox to the textScrollList
	'''
	# Grab selected objects
	selected = cmds.ls(sl=True)
	# Grab selected channelBox objects
	selectedCB = cmds.channelBox('sbaKeyCB', q=True, selectedMainAttributes=True)
	
	# Loop through selected.
	for sel in selected: 
		# Loop through selected channelBox
		for selCB in selectedCB:
			# Put attribute together "object.attribute"
			attr = sel + "." + selCB
			
			# Get all the items inside the textScrollList.
			tslItems = cmds.textScrollList( "sbaKeyTSL", q=True, allItems=True)
			'''
			if( attr in tslItems):
				# Add to your textScrollList
				print( attr + " allready exists inside the textScrollList." )
			else:
				cmds.textScrollList( "sbaKeyTSL", edit=True, append=attr )
			'''
			
			if( tslItems and (attr in tslItems) ):
				# Add to your textScrollList
				print( attr + " allready exists inside the textScrollList." )
			else:
				cmds.textScrollList( "sbaKeyTSL", edit=True, append=attr )
示例#29
0
def loadAttrVal(fld, val, mult):
    '''
	Load the value of the selected attr into the floatField
	'''

    try:  # run code, but catch errors

        # list first selected item into variable
        selItem = cmds.ls(sl=True)

        # list first selected attribute into variable
        selAttr = cmds.channelBox('mainChannelBox', q=True, sma=True)

        # query value of selected attr in channelBox
        attrVal = cmds.getAttr("%s.%s" % (selItem[0], selAttr[0]))

        # edit the floatField to the attr value, multiplied by 1 or -1
        cmds.floatField('%sFltFld%s' % (fld, val), e=True, v=attrVal * mult)

    except TypeError:

        OpenMaya.MGlobal.displayWarning(
            "Please select an attribute from the channel box.")

    except IndexError:

        OpenMaya.MGlobal.displayWarning(
            "Please select an attribute from the channel box.")
示例#30
0
def loadSelAttrFromChbx(txtFldName, *args):
    '''
	Description:
		Fill given text field with selected attribute from channelbox.

	Parameters:
		textFldName: string - Text field widget name.

	Returns:
		None
	'''

    # Get selected attribute on channelbox.
    selObj = cmds.ls(sl=True)[0]
    selAttr = cmds.channelBox('mainChannelBox',
                              q=True,
                              selectedMainAttributes=True)[0]

    # Convert selAttr's short name to long name.
    selAttr = cmds.attributeQuery(selAttr, node=selObj, longName=True)

    # Handle compound attribute.
    prntAttr = cmds.attributeQuery(selAttr, node=selObj, listParent=True)
    if prntAttr:
        selAttr = prntAttr

    # Handle list type selAttr.
    if type(selAttr) == list:
        selAttr = selAttr[0]

    # Fill the given text field.
    cmds.textField(txtFldName, e=True, text=selAttr)