Custom data of vertices, Vertex Layers

I found this answer (first answer) Python: assign custom tag to vertices

I'm pretty excited of this. But I have some questions:

1) How to get all vertices which have 'my_id' custom data?

2) How to remove 'my_id' custom data from all vertices. To clear vertices from unnecessary custom data.

Thanks.

1 Answer

1)

 [i for i in bm.verts if i[my_id]]


This will work because any int value other than 0 will return True. Therefore there's an assumption that you aren't using the value 0 for anything meaningful.

2)

Custom id data is removed after bm.free(). I don't know if it can be wiped before.

for the sake of completeness

>>> import bmesh
>>> bm = bmesh.new()
>>> obj = bpy.context.active_object
>>> bm.from_mesh(obj.data)
>>> my_id = bm.verts.layers.int.new('id')
>>> bm.verts.ensure_lookup_table()
>>> bm.verts[0][my_id]
0


This shows that even before you assign a specific value to your layer.int for that vertex, it will already have a default 0.

• Also, could you say how to remove only one vert from the custom data? Say, "bm.verts[0]" vert. – mifth Jun 2 '15 at 19:41
• i'm not too sure, else I would be more elaborate in my answer. It might be that you should just tag the ones you want to ignore as -1 or something as a token. The documentation is quite sparse and doesn't mention removal as far as I've been able to find. – zeffii Jun 2 '15 at 19:54
• Also, a question: If i remove 'my_id' entire from layers - will the values still be in mesh memory? I mean this "bm.verts.layers.int.remove(my_id)" – mifth Jun 2 '15 at 23:07
• @mifth sorry. comments are not really for asking questions and exchanging answers. The best thing to do is to ask another question with a bit of code to help 'set the scene' (even if you think it overlaps). This helps keep information modular and easier to search on accurate Question titles. – zeffii Jun 3 '15 at 4:57
• In any event, the answer to that question is something you could find for yourself by trying.. setting up a small scene with a icosahedron, adding the above code and experimenting to see if the data persists or not. I assume it does not. – zeffii Jun 3 '15 at 4:59