Indeed there is:  Python comes with the cPickle module, that lets you 
serialize any builtin Python data to disk.  It has a dump method that does 
that writing to your filesystem, but it also had a dumps (dump string) that 
writes it as a string.

In Maya, you can make string attrs on your nodes...

pseudo code, not directly tested but you get the idea

import cPickle

data = {"a":1, "b":2}
stringData = cPickle.dumps(data)

# Add a custom string attr to your node and:
mc.setAttr("myObj.stringAttr", stringData, type='string')

# Then later to query it:
stringAttrData = str(mc.getAttr("myObj.stringAttr"))
loadedData = cPickle.loads(stringAttrData)

print loadedData
{"a":1, "b":2}

I do this *all* the time to just get away from having to deal with Maya's 
own attr types.  So much more flexibility in data storage on Maya nodes.




-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/882c27f4-2c59-4019-bd88-bbb802d9cadd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to