Discovered last week that you can happily set a string attr to any length BUT, and it's a big but, if you subsequently select the textfield (you don't even have to edit it, just select it) then Maya runs a change callback and the string is now clamped to 16bit = 32,767 characters. It was driving me mad last week as I kept getting errors in the json decoder when I tried to read a pose back that I'd serialized to a string on our characterNode. I want to store a zero pose on the Character Node along with some extra data that I'm pushing to a dict, json.dumps is a really nice way to that push that dict to a string and store it and then retrieve it back in it's original form with json.load()
Try it for yourself!
import pymel.core as pCore Cone=pCore.polyCone()[0] Cone.addAttr('json_test', dt='string') data= "x" * 40000 Cone.json_test.set(data) len(Cone.json_test.get()) #>>40000Now just open the Attribute Editor and just select the json_test textfield - don't edit it, just select it
len(Cone.json_test.get()) #>>32767Only thing you can do to stop this truncation is to lock the attr, that way it gets stored correctly and doesn't get truncated.
Mark
No comments:
Post a Comment