Mesh properties API does not allow for zeros in byte array
Closed, ResolvedPublic


easy to reproduce at console with default scene:

layer =["Cube"]"Data")[0].value = bytes([1, 2, 0, 1, 2])



Geoffrey Bantle (briggs) set Type to Bug.Via Old WorldSep 19 2012, 6:37 AM

Confirmed, to support we need to
- add a length variable to the MStringProperty struct. so it can have a length besides 256
- add a callback into rna that can set byte strings - current assignment only takes a 'const char *' which is assumed to be NULL terminated.
... a new callback would have to take a length argument too.

For BMesh support this is simple but for rna a few callbacks would have to support this especially.

Geoffrey Bantle (briggs) added a comment.Via Old WorldSep 20 2012, 7:42 PM

Additionally the name of the property layer is misleading, you cannot actually assign strings at all, it must be a bytes object (which makes it especially broken at the moment). I understand this is probably for historical reasons but thought I should mention it anyway.

Campbell Barton (campbellbarton) added a comment.Via Old WorldJan 9 2013, 2:27 PM

Committed support for bmesh: r53681.
# ---
import bpy
import bmesh

me =

bm = # create an empty BMesh
bm.from_mesh(me) # fill it in from a Mesh

layer =
v = bm.verts[0]
v[layer] = bytes([1, 2, 0, 1, 2])


bm.to_mesh(me) # free and prevent further access

setting as todo

Campbell Barton (campbellbarton) closed this task as "Resolved".Via Old WorldFeb 19 2013, 6:12 PM

Add Comment