
If no joint is specified, use the joint specified by the proxy "jointProxy" proxyGeo: Proxy geometry to to fit to the proxyGeo: joint: Joint to fit the proxy geometry to. LoadedData = cPickle.Source File: proxyMesh.py def proxyFitJoint(proxyGeo,joint='',axis='x'):įit the specified proxy geometry (mesh cylinder) to a given joint. StringAttrData = str(mc.getAttr(objAttr)) # unicode vals, and cPickle wants string, so we convert: # Get the string representation of the pickled data. Return : some Python data : The reconstituted, unpickled Python data. It must have already had valid Python data pickled to it. ObjAttr : string : A valid object.attribute name in the scene. PyToAttr() ) and read it back (unpickle) to valid Python values. Take previously stored (pickled) data on a Maya attribute (put there via Mc.setAttr(objAttr, edit=True, lock=True) Mc.setAttr(objAttr, stringData, type='string') Mc.setAttr(objAttr, edit=True, lock=False) # Make sure attr is unlocked before edit: # Pickle the data and return the coresponding string value: Raise Exception("Object '%s' already has an attribute called '%s', but it isn't type 'string'"%(obj,attr)) If mc.getAttr(objAttr, type=True) != 'string': # Make sure it is the correct type before modifing:


Mc.addAttr(obj, longName=attr, dataType='string') The if the attribute already exists, it must be of type 'string', soĭata : some Python data : Data that will be pickled to the attribute Object exists, but the attribute doesn't, the attribute will be added. ObjAttr : string : a valid object.attribute name in the scene. Later be read back (unpickled) via attrToPy(). Write (pickle) Python data to the given Maya obj.attr. To retrieve the data, I unpickle the string attributes value back to Python data. Making use of the cPickle module, I pickle the Python data to a string object and store to a string attr on a Maya node. But when they did, it was sort of an ‘eureka moment’, and I wrote two functions to make use of this new-found power. It’s not that I was unaware of these topics, it’s just that they’d never occurred in the same mental conversation simultaneously before. Recently I made the connection that A: It’s really easy to serialize (pickle) data in Python, and B: You can make string attributes on nodes in Maya.
