I am very new to blender. I have a scene like this,
The top plane is a cloth, the two cylinders and rectangle are collision objects. I click play on the timeline and get this after a few seconds,
I have this code that generates a point cloud for each center of a face on a mesh. This is the code.
import bpy
def point_cloud(ob_name, coords):
"""Create point cloud object based on given coordinates and name."""
me = bpy.data.meshes.new(ob_name + "Mesh")
ob = bpy.data.objects.new(ob_name, me)
me.from_pydata(coords, [], [])
ob.show_name = True
me.update()
return ob
def face_centers(obj):
"""Returns median center coordinates for each face of given mesh object."""
if obj.type == 'MESH':
import bmesh
bm = bmesh.new()
bm.from_mesh(obj.data)
return [obj.matrix_world @ f.calc_center_median() for f in bm.faces]
else:
return [(0.0, 0.0, 0.0)]
ob = bpy.context.active_object
pc = point_cloud(ob.name + "-pointcloud", face_centers(ob))
# Link object to the active collection
bpy.context.collection.objects.link(pc)
My problem is when I run it, the mesh locations are not updated after the simulation.
You can see the locations of the point cloud is in the original location of the cloth and not in the new updated location after the collisions. How can I get the new updated mesh face coordinates after the simulation has played? The code works as intended its just the mesh face locations are not correct and "outdated".


