#A class called "objectAttr" that works with MEL to create, change, and show a dictionary of a Maya node's attributes #imports Maya and MEL commands import maya.cmds as mc import maya.mel as mel #creates the class class objectAttr: #global variable creation global attrDict attrDict = {} global attrNames attrNames = [] global attrValues attrValues = [] #Because MEL outputs everything to lists, these two work together to output the first selected object's name to a string global selected selected = mc.ls(sl = 1) global sel sel = selected[0] def create(self): #Defines the list of attribute names taht are visible, readable, writable, and keyable attrNames = mc.listAttr(v=1,r=1,w=1,k=1) #For each of the objects in attrNames, append the list attrValues with the value associated with the attribute name for x in attrNames: #this tempSring is used to generate arguements of the type Maya expects tempString = (sel + "." + x) attrValues.append(mc.getAttr(tempString)) #Appends the dictionary with each matching pair of name and value from the two above lists. Uses "z" to z = 0 while z < (len(attrNames)): attrDict[attrNames[z]] = attrValues[z] z += 1 return attrDict #based on the user's input, changes the associated values on the Maya node, then calls the "create" method to repopulate the dictionary def chVal(self,attrName,attrValue): tempString = (sel + "." + attrName) mc.setAttr(tempString,attrValue) self.create() self.shVal() def shVal(self): print attrDict