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.




 [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.


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]

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

  • $\begingroup$ Also, could you say how to remove only one vert from the custom data? Say, "bm.verts[0]" vert. $\endgroup$ – mifth Jun 2 '15 at 19:41
  • $\begingroup$ 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. $\endgroup$ – zeffii Jun 2 '15 at 19:54
  • $\begingroup$ 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)" $\endgroup$ – mifth Jun 2 '15 at 23:07
  • $\begingroup$ @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. $\endgroup$ – zeffii Jun 3 '15 at 4:57
  • $\begingroup$ 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. $\endgroup$ – zeffii Jun 3 '15 at 4:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.