def combineCommand(self, evt=0): shaderList = cmds.textScrollList(Window_global.tsl_shaderList, q=1, selectItem=1) Window_cmds.combineShader(shaderList) existsShader = '' for shader in shaderList: if not cmds.objExists(shader): continue existsShader = shader break if not existsShader: return None cmds.textScrollList(Window_global.tsl_shaderList, e=1, selectItem=existsShader) cmds.swatchDisplayPort(Window_global.swatch, e=1, wh=(64, 64), sn=existsShader) materials = Window_cmds.getMaterials() targetShader = None cmds.textScrollList(Window_global.tsl_shaderList, e=1, ra=1) for material in materials: if material == existsShader: targetShader = material cmds.textScrollList(Window_global.tsl_shaderList, e=1, a=material) cmds.textScrollList(Window_global.tsl_shaderList, e=1, si=targetShader) Window_cmds.selectObjectByMaterials([targetShader])
def aiSwatchDisplayNew(plugName) : nodeAndAttrs = plugName.split(".") node = nodeAndAttrs[0] cmds.formLayout('swatchDisplayForm') cmds.text('swatchLabel', label=aiSwatchLabel(node)) cmds.swatchDisplayPort('swatchDisplay', wh=(64, 64), rs=64) cmds.popupMenu('swatchPopup', button=3) cmds.menuItem( 'swatchSmall', label='Small' ) cmds.menuItem( 'swatchMedium', label='Medium' ) cmds.menuItem( 'swatchLarge', label='Large' ) cmds.setParent(upLevel=True) gTextColumnWidthIndex = mel.eval("$tempVar=$gTextColumnWidthIndex;") cmds.formLayout('swatchDisplayForm', edit=True, af=[('swatchLabel',"top", 0), ('swatchLabel', "bottom", 0), ('swatchDisplay',"top", 0), ('swatchDisplay', "bottom", 0),], aof=[('swatchLabel', "right", -gTextColumnWidthIndex)], an=[('swatchLabel', "left"), ('swatchDisplay', "right")], ac=[('swatchDisplay', "left", 5, 'swatchLabel')] ) aiSwatchDisplayReplace(plugName)
def changeCommand(self, evt=0): materials = Window_cmds.getMaterials() cmds.textScrollList(Window_global.tsl_shaderList, e=1, ra=1) selectIndex = cmds.optionMenuGrp(self.om_shaderType, q=1, select=1) - 2 firstMat = None if selectIndex == -1: for material in materials: if not firstMat: firstMat = material cmds.textScrollList(Window_global.tsl_shaderList, e=1, a=material) else: targetMatType = self.matTypes[selectIndex] firstMat = None for material in materials: if cmds.nodeType(material) == targetMatType: if not firstMat: firstMat = material cmds.textScrollList(Window_global.tsl_shaderList, e=1, a=material) cmds.swatchDisplayPort(Window_global.swatch, e=1, wh=(64, 64), sn=firstMat)
def selectedColor(selectedColorVar): global rgb if selectedColorVar == "Blue": rgb = (0, 0.3412, 0.6588) elif selectedColorVar == "Green": rgb = (0, 0.4823, 0.1569) elif selectedColorVar == "Yellow": rgb = (0.9961, 0.7686, 0) elif selectedColorVar == "Orange": rgb = (0.9059, 0.3882, 0.09412) elif selectedColorVar == "Pink": rgb = (0.933, 0.6157, 0.7647) elif selectedColorVar == "Brown": rgb = (0.3568, 0.1098, 0.0470) elif selectedColorVar == "Purple": rgb = (0.1725, 0.0824, 0.4667) else: rgb = (0, 0, 0) if cmds.swatchDisplayPort("theSwatch", ex=True) == False: cmds.rowColumnLayout(numberOfColumns=1) cmds.swatchDisplayPort("theSwatch", wh=(40, 30), bgc=(rgb[0], rgb[1], rgb[2])) cmds.setParent('..') else: print("Color Fail")
def aiSwatchDisplayNew(plugName): nodeAndAttrs = plugName.split(".") node = nodeAndAttrs[0] cmds.formLayout('swatchDisplayForm') cmds.text('swatchLabel', label=aiSwatchLabel(node)) cmds.swatchDisplayPort('swatchDisplay', wh=(64, 64), rs=64) cmds.popupMenu('swatchPopup', button=3) cmds.menuItem('swatchSmall', label='Small') cmds.menuItem('swatchMedium', label='Medium') cmds.menuItem('swatchLarge', label='Large') cmds.setParent(upLevel=True) gTextColumnWidthIndex = mel.eval("$tempVar=$gTextColumnWidthIndex;") cmds.formLayout('swatchDisplayForm', edit=True, af=[ ('swatchLabel', "top", 0), ('swatchLabel', "bottom", 0), ('swatchDisplay', "top", 0), ('swatchDisplay', "bottom", 0), ], aof=[('swatchLabel', "right", -gTextColumnWidthIndex)], an=[('swatchLabel', "left"), ('swatchDisplay', "right")], ac=[('swatchDisplay', "left", 5, 'swatchLabel')]) aiSwatchDisplayReplace(plugName)
def selectCommand(self, evt=0 ): selList = cmds.textScrollList( Window_global.tsl_shaderList, q=1, selectItem=1 ) cmds.swatchDisplayPort( Window_global.swatch, e=1, wh=(64,64), sn=selList[0] ) cmds.button( Window_global.bt_combine, e=1, en=0 ) ''' cmds.scriptJob( k=Window_global.scriptJob ) Window_global.scriptJob = cmds.scriptJob( e=['SelectionChanged', Window_cmds.selectionChanged ], parent= Window_global.name ) ''' Window_cmds.selectObjectByMaterials( selList ) if len( selList ) > 1 and Window_cmds.isSameMaterials( selList ): cmds.button( Window_global.bt_combine, e=1, en=1 )
def create(self): form = cmds.formLayout() shaderList = cmds.textScrollList(ams=1, selectCommand=self.selectCommand) cmds.popupMenu() cmds.menuItem(l='Select Shader', c=Window_cmds.selectShader) materials = Window_cmds.getMaterials() firstMat = None for material in materials: if not firstMat: firstMat = material cmds.textScrollList(shaderList, e=1, a=material) swatch = cmds.swatchDisplayPort(wh=(64, 64), bgc=[0.5, 0.5, 0.5], sn=firstMat) cmds.setParent('..') cmds.formLayout(form, e=1, af=[(swatch, 'top', 5), (swatch, 'left', 5), (shaderList, 'top', 5), (shaderList, 'right', 5), (shaderList, 'bottom', 5)], ac=[(shaderList, 'left', 3, swatch)]) Window_global.swatch = swatch Window_global.tsl_shaderList = shaderList return form
def aiSwatchDisplayReplace(plugName) : nodeAndAttrs = plugName.split(".") node = nodeAndAttrs[0] cmds.swatchDisplayPort('swatchDisplay', edit=True, shadingNode=node, annotation='Refresh Swatch', pressCommand=lambda *args: mel.eval("updateFileNodeSwatch "+node)) cmds.popupMenu('swatchPopup', edit=True, button=3) cmds.menuItem( 'swatchSmall', edit=True, command=lambda *args: cmds.swatchDisplayPort('swatchDisplay', edit=True, wh=(64, 64), rs=64)) cmds.menuItem( 'swatchMedium', edit=True, command=lambda *args: cmds.swatchDisplayPort('swatchDisplay', edit=True, wh=(96, 96), rs=96)) cmds.menuItem( 'swatchLarge', edit=True, command=lambda *args: cmds.swatchDisplayPort('swatchDisplay', edit=True, wh=(128, 128), rs=128)) cmds.text('swatchLabel', edit=True, label=aiSwatchLabel(node))
def selectCommand(self, evt=0): selList = cmds.textScrollList(Window_global.tsl_shaderList, q=1, selectItem=1) cmds.swatchDisplayPort(Window_global.swatch, e=1, wh=(64, 64), sn=selList[0]) cmds.button(Window_global.bt_combine, e=1, en=0) ''' cmds.scriptJob( k=Window_global.scriptJob ) Window_global.scriptJob = cmds.scriptJob( e=['SelectionChanged', Window_cmds.selectionChanged ], parent= Window_global.name ) ''' Window_cmds.selectObjectByMaterials(selList) if len(selList) > 1 and Window_cmds.isSameMaterials(selList): cmds.button(Window_global.bt_combine, e=1, en=1)
def _create_swatch_display_port_widget(file_node, parent): tmp = cmds.window() cmds.columnLayout() sw = cmds.swatchDisplayPort(h=64, w=64, sn=file_node) ptr = om.MQtUtil.findControl(sw) sw_widget = wrapInstance(long(ptr), QWidget) sw_widget.setParent(parent) sw_widget.resize(64, 64) cmds.deleteUI(tmp) return sw_widget
def changeCommand(self, evt=0 ): materials = Window_cmds.getMaterials() cmds.textScrollList( Window_global.tsl_shaderList, e=1, ra=1 ) selectIndex = cmds.optionMenuGrp( self.om_shaderType, q=1, select=1 ) - 2 firstMat = None if selectIndex == -1: for material in materials: if not firstMat: firstMat = material cmds.textScrollList( Window_global.tsl_shaderList, e=1, a=material ) else: targetMatType = self.matTypes[ selectIndex ] firstMat = None for material in materials: if cmds.nodeType( material ) == targetMatType: if not firstMat: firstMat = material cmds.textScrollList( Window_global.tsl_shaderList, e=1, a=material ) cmds.swatchDisplayPort( Window_global.swatch, e=1, wh=(64,64), sn=firstMat )
def _create_swatch_display_port_widget(file_node, parent): u"""swatchDisplayPortをQWidgetでラップしたオブジェクトを返す""" # swatchDisplayPortにはレイアウトが必要なので、一時的にwindowを作成して削除する tmp = cmds.window() cmds.columnLayout() sw = cmds.swatchDisplayPort(h=64, w=64, sn=file_node) ptr = om.MQtUtil.findControl(sw) sw_widget = QtCompat.wrapInstance(long(ptr), QtWidgets.QWidget) sw_widget.setParent(parent) sw_widget.resize(64, 64) cmds.deleteUI(tmp) return sw_widget
def get_shader(self, shader): """Wrap and return a maya material swatch as a QWidget""" port = cmds.swatchDisplayPort(sn=shader, widthHeight=[32, 32], width=32, height=32, renderSize=32, backgroundColor=[0, 0, 0]) ptr = MQtUtil.findControl(port) qport = shiboken2.wrapInstance(long(ptr), QtWidgets.QWidget) qport.setFixedSize(32, 32) return qport
def combineCommand(self, evt=0): shaderList = cmds.textScrollList( Window_global.tsl_shaderList, q=1, selectItem=1 ) Window_cmds.combineShader( shaderList ) existsShader = '' for shader in shaderList: if not cmds.objExists( shader ): continue existsShader = shader break if not existsShader: return None cmds.textScrollList( Window_global.tsl_shaderList, e=1, selectItem= existsShader ) cmds.swatchDisplayPort( Window_global.swatch, e=1, wh=(64,64), sn=existsShader ) materials = Window_cmds.getMaterials() targetShader = None cmds.textScrollList( Window_global.tsl_shaderList, e=1, ra=1 ) for material in materials: if material == existsShader: targetShader = material cmds.textScrollList( Window_global.tsl_shaderList, e=1, a=material ) cmds.textScrollList( Window_global.tsl_shaderList, e=1, si=targetShader ) Window_cmds.selectObjectByMaterials( [targetShader] )
def makeTextList( scrollListName, description='' ): """Creates the GUI list that contains scene and animation references""" """this list gets referenced all the time and is very important""" cmds.text(label= description ) cmds.separator(style='in') cmds.paneLayout( configuration='vertical2' ) # Use different GUI object depending on if the tab is anim, model, or texture if scrollListName=='animList' or 'modelList': cmds.textScrollList(scrollListName, allowMultiSelection=True, doubleClickCommand=lambda *args:selectObject( scrollListName ), deleteKeyCommand=lambda *args:editAttribute( scrollListName, mode='Delete' ), selectCommand=lambda *args:updateTextFields( scrollListName, mode='Select' ), bgc=[0.0,0.3,0.0], annotation="Double click to select object" ) # For textures else: cmds.columnLayout('textureSwatches') cmds.swatchDisplayPort(scrollListName, wh=(300, 500), backgroundColor=[0.1, 0.1, 0.1]) cmds.setParent('..')
def aiSwatchDisplayReplace(plugName): nodeAndAttrs = plugName.split(".") node = nodeAndAttrs[0] cmds.swatchDisplayPort( 'swatchDisplay', edit=True, shadingNode=node, annotation='Refresh Swatch', pressCommand=lambda *args: mel.eval("updateFileNodeSwatch " + node)) cmds.popupMenu('swatchPopup', edit=True, button=3) cmds.menuItem('swatchSmall', edit=True, command=lambda *args: cmds.swatchDisplayPort( 'swatchDisplay', edit=True, wh=(64, 64), rs=64)) cmds.menuItem('swatchMedium', edit=True, command=lambda *args: cmds.swatchDisplayPort( 'swatchDisplay', edit=True, wh=(96, 96), rs=96)) cmds.menuItem('swatchLarge', edit=True, command=lambda *args: cmds.swatchDisplayPort( 'swatchDisplay', edit=True, wh=(128, 128), rs=128)) cmds.text('swatchLabel', edit=True, label=aiSwatchLabel(node))
def createUi(self): nodeStrId = self.node.name() swatchCmd = 'import bpj_shaderAndTextureLister as satl\nsatl.onShadingNodePressed("' + nodeStrId + '")' txSwatch = cmds.swatchDisplayPort(sn = nodeStrId, wh = (self.iconSize, self.iconSize), renderSize = self.iconSize, pressCommand = swatchCmd) filePath = cmds.getAttr(nodeStrId + '.fileTextureName') if filePath != '': label = os.path.basename(filePath) else: label = 'No file referenced!' labelCmd = 'import bpj_shaderAndTextureLister as satl\nsatl.browseForTexture("' + nodeStrId + '")' self.hLabel = cmds.iconTextButton(label = label, height = self.iconSize/2, style = 'iconAndTextHorizontal', commandRepeatable = 0, command = labelCmd) openFileCmd = 'import bpj_shaderAndTextureLister as satl\nsatl.browseForTexture("' + nodeStrId + '")' openFileBtn = cmds.iconTextButton(label = 'Load Texture', annotation = 'Browse for a file on your computer...', image1 = 'freeformOff.png', height = self.iconSize/2, width = self.iconSize/2, style = 'iconOnly', commandRepeatable = 0, command = openFileCmd) viewFileCmd = 'import bpj_shaderAndTextureLister as satl\nsatl.viewTexture("' + nodeStrId + '")' viewFileBtn = cmds.iconTextButton(label = 'View Texture', annotation = 'View texture file with your preferred image viewer', image = 'freeformOff.png', height = self.iconSize/2, width = self.iconSize/2, style = 'iconOnly', commandRepeatable = 0, command = viewFileCmd) editFileCmd = 'import bpj_shaderAndTextureLister as satl\nsatl.EditTexture("' + nodeStrId + '")' editFileBtn = cmds.iconTextButton(label = 'Edit Texture', annotation = 'Edit texture file with your preferred image editor', image = 'freeformOff.png', height = self.iconSize/2, width = self.iconSize/2, style = 'iconOnly', commandRepeatable = 0, command = editFileCmd) openFileLocCmd = 'import bpj_shaderAndTextureLister as satl\nsatl.openTextureLocation("' + nodeStrId + '")' msg = 'LMB: Open texture file location in explorer\n' msg += 'LMB+Shift: Copy file path to clipboard\n' msg += 'LMB+Alt: Copy folder path to clipboard' openFileLocBtn = cmds.iconTextButton(label = 'Open Texture Location', annotation = msg, image = 'freeformOff.png', height = self.iconSize/2, width = self.iconSize/2, style = 'iconOnly', commandRepeatable = 0, command = openFileLocCmd) cmds.formLayout( self.listItemLayoutId, edit = 1, backgroundColor = self.backgroundColor, annotation = os.path.normpath(filePath), attachForm = [(txSwatch, 'left', 0), (self.hLabel, 'right', 0)], attachControl = [ (self.hLabel, 'left', 0, txSwatch), (openFileBtn, 'left', 10, txSwatch), (openFileBtn, 'top', 0, self.hLabel), (viewFileBtn, 'left', 0, openFileBtn), (viewFileBtn, 'top', 0, self.hLabel), (editFileBtn, 'left', 0, viewFileBtn), (editFileBtn, 'top', 0, self.hLabel), (openFileLocBtn, 'left', 0, editFileBtn), (openFileLocBtn, 'top', 0, self.hLabel) ] ) # scriptjob for updating the label of the NodeListItem cmd = 'import bpj_shaderAndTextureLister as bpj_stl;' cmd+= 'import maya.cmds as cmds;' cmd+= 'bpj_stl.NodeListItem.updateLabel("%s", cmds.getAttr("%s.fileTextureName"))' %(self.hLabel, nodeStrId) cmds.scriptJob(parent = self.hLabel, attributeChange = [nodeStrId + '.fileTextureName', cmd])
def createUi(self): nodeStrId = self.node.name() swatchCmd = 'mel.eval(\'showEditorExact \"' + nodeStrId + '\";\')' shSwatch = cmds.swatchDisplayPort(sn = nodeStrId, wh = (self.iconSize, self.iconSize), renderSize = self.iconSize, pressCommand = swatchCmd) self.hLabel = cmds.iconTextButton(label = nodeStrId, height = self.iconSize, style = 'iconAndTextHorizontal', commandRepeatable = 0, c = 'import bpj_shaderAndTextureLister as satl\nsatl.onShadingNodeLabelPressed("' + nodeStrId + '")') shCollapseChkbx = cmds.iconTextButton(label = 'Collapse/Expand', annotation = 'collapse shader', width = 18, height = self.iconSize, style = 'iconOnly', image1 = 'bpj_nodeListItemArrowDown_64.png', commandRepeatable = 0) # self.setColorCode() cmds.formLayout( self.listItemLayoutId, edit = 1, backgroundColor = self.backgroundColor, annotation = nodeStrId, attachForm = [ (shSwatch, 'left', 0), (shCollapseChkbx, 'right', 0), (shSwatch, 'top', 0), (self.hLabel, 'top', 0), (shCollapseChkbx, 'top', 0), ], attachControl = [ (self.hLabel, 'left', 0, shSwatch), (self.hLabel, 'right', 0, shCollapseChkbx) ])
def create(self): form = cmds.formLayout() shaderList = cmds.textScrollList( ams=1, selectCommand = self.selectCommand ) cmds.popupMenu() cmds.menuItem( l='Select Shader', c = Window_cmds.selectShader ) materials = Window_cmds.getMaterials() firstMat = None for material in materials: if not firstMat: firstMat = material cmds.textScrollList( shaderList, e=1, a=material ) swatch = cmds.swatchDisplayPort( wh=(64,64), bgc = [0.5, 0.5, 0.5], sn=firstMat ) cmds.setParent( '..' ) cmds.formLayout( form, e=1, af=[ ( swatch, 'top', 5 ), ( swatch, 'left', 5 ), ( shaderList, 'top', 5 ), ( shaderList, 'right', 5 ), ( shaderList, 'bottom', 5 ) ], ac=[ ( shaderList, 'left', 3, swatch )]) Window_global.swatch = swatch Window_global.tsl_shaderList = shaderList return form
def SundayUIToolsDockedShaderlinerUpdate(): selected = cmds.ls(selection = True) if cmds.scrollLayout('sundayShaderlinerInTheDockScroll', query = True, exists = True): cmds.deleteUI('sundayShaderlinerInTheDockScroll') cmds.setParent(cmds.menuBarLayout('sundayShaderlinerInTheDockMenuBarLayout', query = True, fullPathName = True)) sSParent = cmds.scrollLayout('sundayShaderlinerInTheDockScroll', childResizable = True) cmds.scriptJob(event = [ 'deleteAll', SundayUIToolsDockedShaderlinerKillJobs], parent = sSParent) cmds.hyperShade('', shaderNetworksSelectMaterialNodes = True) selShader = cmds.ls(selection = True) shaders = cmds.ls(materials = True) shaders.sort() isSwatch = cmds.optionVar(query = 'SundayShaderlinerSwatch') for curShader in shaders: isRef = cmds.referenceQuery(curShader, isNodeReferenced = True) if len(selShader) > 0: if selShader[0] == curShader: cmds.rowLayout(numberOfColumns = 3, height = 44, columnWidth3 = (40, 75, 108), adjustableColumn = 2, backgroundColor = [ 4.60052e+18, 4.60052e+18, 4.60052e+18]) else: cmds.rowLayout(numberOfColumns = 3, height = 44, columnWidth3 = (40, 75, 108), adjustableColumn = 2) else: cmds.rowLayout(numberOfColumns = 3, height = 44, columnWidth3 = (40, 75, 108), adjustableColumn = 2) cmds.popupMenu(button = 3, markingMenu = True) cmds.menuItem(enable = False, label = 'Input-Output Connection in Hypershade', command = 'import SundayUIToolsPy\nreload(SundayUIToolsPy)\nSundayUIToolsPy.SundayUIToolsDockedShaderlinerInputOutputInHypershade("' + curShader + '")') if isSwatch: cmds.swatchDisplayPort(sn = curShader, pressCommand = 'cmds.select("' + curShader + '")', widthHeight = [ 40, 40], renderSize = 40) else: cmds.iconTextButton(image1 = SundayImage + 'SundaySolidSphere.png', command = 'cmds.select("' + curShader + '")', backgroundColor = [ 4.59637e+18, 4.59637e+18, 4.59637e+18], height = 40, width = 40) cmds.columnLayout() cmds.text(label = curShader) cmds.separator(height = 4) if isRef: cmds.text(label = 'Ref : ' + cmds.nodeType(curShader), font = 'tinyBoldLabelFont') else: cmds.text(label = cmds.nodeType(curShader), font = 'tinyBoldLabelFont') cmds.setParent('..') cmds.rowLayout(numberOfColumns = 2, adjustableColumn = 2) cmds.columnLayout() cmds.button(label = 'Apply', command = 'cmds.hyperShade(assign="' + curShader + '")', height = 19, width = 50) if curShader == 'lambert1' or curShader == 'particleCloud1': cmds.button(enable = False, label = 'Clone', command = 'cmds.select("' + curShader + '")\ncmds.duplicate( upstreamNodes=True )\nimport SundayUIToolsPy\nreload(SundayUIToolsPy)\nSundayUIToolsPy.SundayUIToolsDockedShaderlinerUpdate()', height = 19, width = 50) else: cmds.button(label = 'Clone', command = 'cmds.select("' + curShader + '")\ncmds.duplicate( upstreamNodes=True )\nimport SundayUIToolsPy\nreload(SundayUIToolsPy)\nSundayUIToolsPy.SundayUIToolsDockedShaderlinerUpdate()', height = 19, width = 50) cmds.setParent('..') if curShader == 'lambert1' and curShader == 'particleCloud1' or isRef: cmds.columnLayout(enable = False) else: cmds.columnLayout() cmds.button(label = 'Delete', command = 'cmds.select("' + curShader + '")\ncmds.delete()\nimport SundayUIToolsPy\nreload(SundayUIToolsPy)\nSundayUIToolsPy.SundayUIToolsDockedShaderlinerUpdate()', height = 19, width = 50) cmds.button(label = 'Rename', command = 'import SundayUIToolsPy\nreload(SundayUIToolsPy)\nSundayUIToolsPy.SundayUIToolsDockedShaderlinerRename("' + curShader + '")', height = 19, width = 50) cmds.setParent('..') cmds.setParent('..') cmds.setParent('..') cmds.separator(style = 'in') SundayShaderlinerJobScriptJob.append(cmds.scriptJob(nodeNameChanged = [ curShader, SundayUIToolsDockedShaderlinerKillJobs], runOnce = True, parent = sSParent)) SundayShaderlinerJobScriptJob.append(cmds.scriptJob(nodeDeleted = [ curShader, SundayUIToolsDockedShaderlinerKillJobs], runOnce = True, parent = sSParent)) cmds.setParent('..') try: cmds.select(selected) except: pass
def editAttribute(scrollListName, mode='', newItem=None): # This is going to have to change if scrollListName != 'textureList': selectedListItems = cmds.textScrollList(scrollListName, query=True, si=True) selectedSceneObjects = cmds.ls(sl=True) if scrollListName == 'animList': # Find object where data is stored, it's attribute, and get attr data dataObject, attrName, attrData = getAttribute(scrollListName) # Save min and max of current time range timeRange = [ cmds.playbackOptions(query=True, min=True), cmds.playbackOptions(query=True, max=True) ] if mode == 'AddRange': # user names the animation animName = raw_input("Name the animation") # check if user gave a name if animName: attrData.append([animName,timeRange]) setAttribute(scrollListName, attrName=attrName, data=attrData, mode='SetData') if mode == 'RestoreRange': # get frame range of selected animation, and apply it frameRange = eval(attrData[selectedListItems[0]]) cmds.playbackOptions(min=frameRange[0], max=frameRange[1]) if mode == 'DeleteRange': # Go through selection in case of multiple simultaneous deletions for animName in selectedListItems: # Iterate though list, find match for animName and delete it for index, value in enumerate(attrData): if value[0] == animName: attrData.remove(value) cmds.textScrollList(scrollListName, edit=True, removeItem=animName) # Set attribute with new data setAttribute(scrollListName, attrName=attrName, data=attrData, mode='SetData') # NOT USED if mode == 'RefreshAll': cmds.textScrollList(scrollListName, edit=True, removeAll=True) updateTextList(scrollListName, mode='RefreshAll') if scrollListName == 'modelList': # Used to initialize new object into list if mode == 'Add': # Create empty dictionary to pass many objects and their attributes to the setAttribute() function attrData = [] for object in selectedSceneObjects: # Create attribute name for object attrName = object +'.'+ scrollListName # Check if attribute exists, if not, initialize it if not cmds.objExists(attrName): cmds.addAttr(object, longName=scrollListName, dataType='string') # Add new entry to list attrData.append( [scenePath,attrName] ) # Create attributes setAttribute(scrollListName, attrName=attrName, data=attrData, mode='SetData') # Delete object from list and it's attribute if mode == 'Delete': deleteAttribute(scrollListName) if scrollListName == 'textureList': print "Texture list stuff goes here" if mode == 'Add': print "Add material to list" mat = cmds.ls(sl=True)[0] cmds.swatchDisplayPort(scrollListName, edit=True, shadingNode=mat, borderWidth=2) if mode == 'Delete': print "Deleting material from list"