Polygon String Layer Problem

I’m having some trouble with polygon string layers.

I start with Blender 2.75 after loading factory settings. I then get the default cube’s mesh:

>>> cube = bpy.data.objects['Cube']
>>> cmesh = cube.data

I create an integer layer, check it, set it, and check it again:

>>> myintlayer = cmesh.polygon_layers_int.new(name='my_int_layer')
>>> myintlayer.data[0].value
0
>>> myintlayer.data[0].value = 123
>>> myintlayer.data[0].value
123

All is fine. I repeat the process for a float layer:

>>> myfloatlayer = cmesh.polygon_layers_float.new(name='my_float_layer')
>>> myfloatlayer.data[0].value
0.0
>>> myfloatlayer.data[0].value = 123.456
>>> myfloatlayer.data[0].value
123.45600128173828

Again, all is fine. But then I try it with a string layer:

>>> mystringlayer = cmesh.polygon_layers_string.new(name='my_string_layer')
>>> mystringlayer.data[0].value
b'\x00'
>>> mystringlayer.data[0].value = b'abc'
>>> mystringlayer.data[0].value
b'\x00'

It doesn’t complain about the assignment, but the value doesn’t “stick”. I still get b’\x00’.

Any ideas?

P.S. I just tried it on the newly released 2.76rc1 and got the same results. I suspect I’m doing something wrong with the specification of the string, but I’m not sure what.

I personally never tried the standard API custom data layer stuff, if appears to be incomplete and buggy.
You should try the bmesh module API instead:
http://www.blender.org/api/blender_python_api_2_75_release/bmesh.html#customdata-access

Thanks as always for taking the time to respond!!!

I don’t mind trying the bmesh API, but I just want to check back with you to see if it will work as expected.

We have an application where we want to “tag” certain faces of arbitrary mesh objects with a marker that let’s us know what’s been marked. We would like that “tag” to stay with the faces even if the object is edited (if at all possible). The tags also have to remain with the faces when saved to and restored from a .blend file.

We had been just keeping track of the face’s index values within the mesh (using a regular property array), but certain operations seem to scramble and renumber the faces. So we’re looking for a way to put a known tag on a known face and have it survive as much manipulation as possible.

We’ve considered using materials for this, but that seems like an abuse of the material system (a lot of materials for a lot of tags). The Integer/Float/String layers “look” like the right solution, but we’re not even sure how much editing they can take and remain consistent. If using a bmesh will work, then that would be a great solution and we’ll pursue it.

With that additional explanation, do you think bmesh will do the trick or is there another avenue you’d recommend?

Thanks in advance.

Yeah a bmesh custom data layer should do the trick.