I am trying to adapt a py tool that saves and reads smooth skin data to a file.
(part of an avatar clothing system that loads the mesh and skins form the file)
My crazy idea is to save and read this data as an added attribute to the mesh.
It seems like something like this should do it:
cmds.saddAttr('meshName.skinData',type='stringArray')
dataCount=373
dataElementString= (' "longStringOfData1","longStringOfData2"..."longStringOfData323", ')
#note extra comma at end of dataElementString -from my badly hacking the other code
cmds.setAttr('meshName.skinData' , dataCount , dataElementString , type='stringArray')
but it I get an error that setAttr has problems reading element 3 -which I assume is dataElementString.
Do I need further formatting of dataElementString?
or is that extra comma causing havok?
You might be able to serialize all the data into a single XML string that represents the separate parts. Then you can store that in the .notes attribute, or a regular user string attr rather than an array. I recommend cElementTree over dom.minidom. http://effbot.org/zone/celementtree.htm
An attribute of type “string” seems to have a size limit, my data gets cut short when I try writing to it. ( i could be wrong)
I’ll try the notes attribute and see what happens…
I’d try serializing it to something like a JSON string and pushing that onto the attribute. We use this method to serialize Pose data and all sorts of complex nodes to an attribute, we’ve not hit any string size limit yet and we’ve done all sorts. The beauty of JSON is it’s dead easy to serialize and deserialize back to a python object.
[QUOTE=Mark-J;16549]… we’ve not hit any string size limit yet and we’ve done all sorts…[/QUOTE]
hmmm…I wonder what’s going on then…it seems like the data that gets written to a string attribute is cut short. I’ll have to test this.
JSON struck me as good idea too, but the tool I’m adapting has read write functions for this custom format (in turn used by other tools), and I’m trying to avoid rewriting too much. Lazy, I know:)
Found the problem:
the attribiute editor’s text field for ‘extra attributes’ of type string has a limit.
I can write a big chunk of data
but if I touch the field in the attribiute editor, it automatically gets truncated to the upper limit of the text field:sigh:
It seems that clicking on any field in the attribute editor executes the setAttr() MEL command, and passes the current contents of the field as its argument for the new value. Because the text field input area for a string attribute appears to have a character limit, this cause the data to truncate when selected.
the docs on the textField object mention no size limit, so this appears unique to the attribute editor.