This has me stumped.
import bpy
meshes = bpy.data.meshes
objects = bpy.data.objects
scene = bpy.context.scene
def new_mesh(name):
verts = [(3, 3, -3), (3, -3, -3), (-3, -3, -3)]
edges = [(0, 1),(1,2),(2,0)]
mesh_data = meshes.new(name)
mesh_data.from_pydata(verts, edges, [])
mesh_data.update()
return mesh_data
mesh = new_mesh('some_mesh')
obj = objects.new('example_obj', mesh)
scene.objects.link(obj)
obj.modifiers.new(type='SKIN', name='sv_skin')
print(len(obj.data.skin_vertices))
# now switch the mesh to a new one.
obj.data = new_mesh('some_other_mesh')
print(len(obj.data.skin_vertices))
This snippet demonstrates a problem I'm having. Once i've added a Skin Modifier to the object, and then change the mesh data by assigning a new mesh to .data, then skin_vertices seems to be empty.
Yes there are workarounds.
@stacker below points out that I can remove and add the modifier to make skin_vertices again. This is a solution I use already, but it results in a lot of extra code to make sure other modifiers stay in the right place. In viewer_skin.py (linked to) I am hardcoding the modifiers, but you should imagine that I don't want to make any assumptions about which modifiers are on that stack at all (except for the skin modifier)
I'm trying to not use bpy.ops.object.modifier_(move_up, move_down, add)
because that requires an active object.