3

I am trying to access skin modifier vertices data. An older solution does not work in my Blender 2.75 / 2.76:

print('has skin=', bool(context.active_object.modifiers['Skin']))
data = context.active_object.data
print(data)
vert = data.skin_vertices
print('skin_vertices=', vert)
v0d = data.skin_vertices[0]
print('skin_vertices[0]=', v0d)
v0d_data = v0d.data
print('skin_vertices_data=', v0d_data)
print('--------loop--------')
for v in v0d_data:
    print('skin_vertex=', v)

That returns:

has skin= True  
bpy_struct, Mesh("Skin")  
skin_vertices= bpy_collection[1], Mesh.skin_vertices  
skin_vertices[0]= bpy_struct, MeshSkinVertexLayer("")  
skin_vertices_data= bpy_collection[4], MeshSkinVertexLayer.data  
--------loop--------  

According to python api skin_vertices return MeshSkinVertexLayer not MeshSkinVertex, what we see in print data.

Bmesh also has a some skin data BMesh.verts.layers.skin, but it doesn't return any useful data.

Is there any way to access skin data?

Marek
  • 31
  • 3
  • 2
    do it in Object mode when using obj.data.skin_vertices[0].data directly. Edit Mode will not output anything – zeffii Sep 27 '15 at 21:38
  • Thanks, its work. Mesh in EDIT mode return skin data and might be modified. – Marek Sep 28 '15 at 22:20
  • Why not generate a new mesh with modifiers applied via: bpy.context.object.to_mesh( bpy.context.scene, True, 'RENDER' )? – TLousky Sep 29 '15 at 11:45

1 Answers1

1

The original question you link to mentions this in the first line, but doesn't make a point to clarify why the Object/Edit mode switch is important.

Non BMesh

When using obj.data.skin_vertices[0].data, the Skin Modifier data will show the correct current values only when the object is put back in Object Mode. The same is also true for checking other information of the mesh, like vertex.select.

BMesh

It may be possible to get this skin information while still in Edit Mode using bm = bmesh.from_edit_mesh(obj.data) but I have not been able to find an obvious way. If it is possible someone will no doubt offer a suggestion.

zeffii
  • 39,634
  • 9
  • 103
  • 186