Hello community.
I am working right now on my addon an I want to use polygons Freestyle masking feature as an option for masking things I do with my addon.
I found how it is possible to read freestyle data from object data.
bpy.data.objects['object_name'].data.id_data.polygons[0].use_freestyle_mark
The problem is that if some changes were done to mesh during editing those changes are not presented in object data and I do not understand how to handle it from edit mode with Bmesh. I assume in Bmesh this data stored in faces.layers.freestyle
(didn’t found any signs of “freestyle” anywhere else)
I thought that I could read it same way as I do with vertex clolor from loops.layers.color
First I assign clolor layer as some variable and then use it this way
bmd = bmesh.from_edit_mesh(context.edit_object.data)
llc = bmd.loops.layers.color[0]
bmd.faces[0].loops[0][llc]
It returns me vertex color for this loop in Vector format.
When I try to do same for faces.layers.freestyle
bmd = bmesh.from_edit_mesh(context.edit_object.data)
flf = bmd.faces.layers.freestyle[0]
freestyle[0]
because when I try to print it I have <BMLayerItem object at 0x0000028007A01CE0>
, with [1]
or anything else I have IndexError: BMLayerCollection[index]: index 1 out of range
bmd.faces[0][flf]
returns me some NotImplemented
Is this literally “not implemented” feature to have access to freestyle mask data from Bmesh or I doing something wrong?
I would like to make my addon free from unnecessary jumping out from edit mode only to read some object data and then jump back to edit. Maybe someone here have more experience dealing with this thing, it would be nice to have any help/advices.
If it really not wrok from Bmesh - maybe someone could at least help me to guess how to update particular object mesh data without jumping out from edit mode.
Using bpy.data.objects['object_name'].data.id_data.update()
not update this freestyle data as far as I see from my test.
I found old topic How to update mesh data in edit mode? but I do not understant at all what it is about. It has some example is_success_update_data = object.update_from_editmode()
, but what is this is_success_update_data
and how I could update actual object data for particular object with that? With Bmesh I create something from oject data bmd = bmesh.from_edit_mesh(bpy.context.edit_object.data)
and then poke it to get what I need, but what should I do to rewrite object data with this update_from_editmode()
?