[Addon] Non destructive modelling - snapshot Meshes

Thank you so much for this! This is an awesome add-on and I’m really happy to see it in 2.80+.

There’s just a small non-fatal error, though. Once you delete all snapshots, it still tries to set a snapshot and, therefore, it gives an index out of range error. Specifically it’s line 354 in the selectSnapShotMesh function. The error is:

ssMeshName = context.object.snapShotMeshes[self.snapShotMesh_ID_index].snapShotMeshName

My guess is that it’s trying to access context.object.snapShotMeshes[0], which doesn’t exist. Setting the “if” condition on line 353 to > 0 instead of > -1 seems to fix the problem.

EDIT: Upon further inspection, setting the “if” condition to 0 does not fix the problem. It gets rid of the error, but the mesh is not actually reset to the first snapshot before it is deleted. However, this does seem to fix things correctly:

try:
    ssMeshName = context.object.snapShotMeshes[self.snapShotMesh_ID_index].snapShotMeshName
    snapShotMesh = bpy.data.objects[ssMeshName]
    useSnapShot(bpy.context.active_object, snapShotMesh)
except:
    pass