PyNodes already have special code to ensure they will pickle, and they will correctly unpickle as long as the maya objects in the pickle exist in the current scene. the question is, "what should pymel do if the node/attr does not exist?"
> > Ah-hah! That's cool. > So, I actually ran into a very similar problem on Monday: I was > trying to use pickle to store objects built via functools.partial > (which I suppose you could equate to a PyNode class instance in this > case), but pickle said it couldn't do it, which was a bummer (no > pickling functools.partial objects). What I did instead was write my > own custom class (very simple) that wrappered all the args I was > passing into my functools.partial object (basically, the creation > state args). That custom class was easily pickleable. When I > unpickled that data, I passed those args back into the the function > that made my objects in the scene (in this case PyMel presumably), and > pow, there they appeared. Kind of convoluted, but it works. > > On Oct 27, 8:49 am, chadrik <[email protected]> wrote: >>> I don't use pymel, but I do use Python and pickle in Maya ;) From >>> your above example, it looks like x is a tuple with two strings in >>> it? Or is pymel storing more complex objects as the name >>> representation of the nodes rather than strings? >> >> yeah, pymel represents nodes as instances of a PyNode class, not >> simple strings. these node class instances themselves store >> instances >> of the underlying api objects that they represent, so this data has >> to >> be rebuilt. strings are so 2006 ;) >> >> -chad > > --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/python_inside_maya -~----------~----~----~----~------~----~------~--~---
