I want to approach two vertex groups belonging to two different objects, making sure that these objects are close together. How can I do that scripting?
Thank you so much!
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It only takes a minute to sign up.Sign up to join this community
Given an object
ob, you can access its mesh at
ob.data, and its vertices at
ob.data.vertices. The vertex groups are defined on the object as well, at
ob.vertex_groups. Each vertex group has a
weight() function you can call to get the weight of a vertex.
vg0 = ob.vertex_groups for index, vertex in enumerate(ob.data.vertices): try: weight = vg0.weight(index) except RuntimeError: # Raised when the vertex is not part of the group weight = 0.0 print('Vertex #%d at %s has weight %f' % (index, vertex.co, weight))
For efficient distance queries (from a point in space to a mesh) you can use the BVHTree module. This may work faster than trying to compute the distance between every point of one mesh to every other point on the other.