I have been struggling with trying to find a way to do this. It's related to my previous efforts here: How to get list of bm.verts that belong to a deform layer? When I do this
for vert in bm.verts:
dvert = vert[layer_deform]
I get a dictionary of deform layer numbers (keys) and weights (values) per bm.vert. What I'd like to achieve is a list containing lists of verts, based on their deform layer (vertex group) number. So it should look something like this:
vertex_lists = [[<BMVert(0x000002A7818090B0), index=12>, <BMVert(0x000002A7818090E8), index=13>], [<BMVert(0x000002A7818090B0), index=15>, <BMVert(0x000002A7818090E8), index=20>], [<BMVert(0x000002A7818090B0), index=44>, <BMVert(0x000002A7818090E8), index=24>]]
I'd like to achieve this in order to automate further bmesh.ops. I am guessing I need to find a way to iterate over bm.verts and append them to a list based on their layer deform key (vertex group number). How do I group the verts into separate lists based on their respective layer_deform numbers?
defaultdict. Re comments above i) check your logic, ii) time the code, iii) will fail when there are empty vertex groups. – batFINGER Mar 25 '19 at 06:17