0
$\begingroup$

I created a mesh in a script that has 5 vertices and each vertex is moved by an empty using Hook constraints. This animates the plane to follow the path of a spinning torus based on the animation I had on the empties. The pivot point is at the center of the mesh.

I want to access the location and rotation of the full object. However, when I look at the location and rotation, is not changing and the rotation is always 0, 0, 0 no matter what rotation type I use. Any ideas what could be causing this? I just need the values of its location and rotation on each frame.

This is how I create the mesh... not sure if there is a way that can give me better results:

bpy.ops.object.mode_set(mode='EDIT', toggle=False)
mesh = bpy.data.meshes.new("myBeautifulMesh")  # add the new mesh
obj = bpy.data.objects.new(mesh.name, mesh)
col = bpy.data.collections.get("Collection")
col.objects.link(obj)
bpy.context.view_layer.objects.active = obj

verts = [order[0].location, 
         order[1].location,
         order[2].location,
         order[3].location,
         order[4].location
         ]  # 4 verts made with XYZ coords
edges = []
faces = [[0, 1, 2, 3, 4]]

mesh.from_pydata(verts, [], faces)
$\endgroup$
1
$\begingroup$

Modifiers alter mesh at a local level

The hook modifier, or most modifiers modify the mesh data, not the object transform.

The location of the hooked object could be estimated from all the hook empties (average there global translations).

Or use a copy location constraint. Add all the verts to one group, make that the constraint target. The rotation can be estimated (depends on mesh) using track to constraints.

For rotation consider parenting.

Can parent an object to 3 of the beautiful mesh vertices.

See this answer https://blender.stackexchange.com/a/175503/15543 The modifier for this case is shrinkwrap. The cubes are parented to 3 vertices modified "foot" object.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks! This makes a lot more sense and works! I followed your advice and used the script from the other stack exchange answer to parent the mesh of the ring to 3 vertices. However, I still can't access the data of its location and rotation in the world space... any hints on that part? $\endgroup$ – Jackie May 21 at 17:02
  • $\begingroup$ In example would use the matrix world of the cube. ie parent an empty to 3 verts of your ring. The empties matrix world is an estimation of global transform of ring. $\endgroup$ – batFINGER May 21 at 17:23
  • $\begingroup$ Okay thank you! Makes sense 👍 $\endgroup$ – Jackie May 21 at 17:27

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.