2
$\begingroup$

I have a rigid body simulation in Blender 2.79. The simulation is very simple, a rounded body is rolling and bouncing down on an inclined plane and I would like to process the motion data in another software.

Is it possible to export the position and orientation of the body in every frame? I am a beginner assuming it would require an addon, but I could not find anything useful.

Edit: Assume we have a local coordinate system attached to the body. I would like to export the position and orientation of the local system with respect to the global one. So a possible output would be a text file with 9 columns (x0,y0,z0 positions of the origin of the local system, and at least two direction vectors of the local x and y axes (of course the z axis can be computed later if needed)). The number of lines in the file would be the number of frames computed during the simulation.

$\endgroup$
6
  • $\begingroup$ do you mean tabulated X,Y,Z rotations, position and scale? $\endgroup$ Commented Jun 25, 2021 at 18:50
  • $\begingroup$ you can keyframe the animation - if you mean that. But as you can see - your question is not clear enough. If it would be - we wouldn't have to ask. So please improve your question. $\endgroup$
    – Chris
    Commented Jun 25, 2021 at 18:54
  • $\begingroup$ It depends what kind of file format you need to export ... $\endgroup$
    – vklidu
    Commented Jun 25, 2021 at 19:12
  • $\begingroup$ Sorry for the ambiguity of my question, I edited it and hope it provides the details you requested. $\endgroup$
    – BalazsToth
    Commented Jun 25, 2021 at 19:38
  • 1
    $\begingroup$ Some time ago I looked through the Python properties trying to find location and rotation of the physics engine controlled objects and was unsuccessful. $\endgroup$
    – Ron Jensen
    Commented Jun 25, 2021 at 19:42

1 Answer 1

1
$\begingroup$
  1. keyframe your animation

then use this script:

import bpy

obj = bpy.context.selected_objects[0] # of course you could get your object in better ways, i chose this to be quick ;)

for frame in range(1,30): # here you can also get your frame range in a better way...this is just a prototype, how it works, not how to show what's the best way
    
    bpy.context.scene.frame_set(frame)
    print (frame, obj.location, obj.rotation_euler)

possible output:

1 <Vector (0.0000, 0.0000, 2.7796)> <Euler (x=-0.6051, y=-0.0003, z=-0.2745), order='XYZ'> 2 <Vector (0.0000, 0.0000, 2.7702)> <Euler (x=-0.6051, y=-0.0003, z=-0.2745), order='XYZ'> 3 <Vector (0.0000, 0.0000, 2.7439)> <Euler (x=-0.6051, y=-0.0003, z=-0.2745), order='XYZ'> 4 <Vector (0.0000, 0.0000, 2.7005)> <Euler (x=-0.6051, y=-0.0003, z=-0.2745), order='XYZ'> 5 <Vector (0.0000, 0.0000, 2.6403)> <Euler (x=-0.6051, y=-0.0003, z=-0.2745), order='XYZ'> 6 <Vector (0.0000, 0.0000, 2.5631)> <Euler (x=-0.6051, y=-0.0003, z=-0.2745), order='XYZ'> 7 <Vector (0.0000, 0.0000, 2.4690)> <Euler (x=-0.6051, y=-0.0003, z=-0.2745), order='XYZ'> 8 <Vector (0.0000, 0.0000, 2.3580)> <Euler (x=-0.6051, y=-0.0003, z=-0.2745), order='XYZ'> 9 <Vector (0.0000, 0.0000, 2.2303)> <Euler (x=-0.6051, y=-0.0003, z=-0.2745), order='XYZ'> 10 <Vector (0.0000, 0.0000, 2.0857)> <Euler (x=-0.6051, y=-0.0003, z=-0.2745), order='XYZ'> 11 <Vector (0.0000, 0.0000, 1.9243)> <Euler (x=-0.6051, y=-0.0003, z=-0.2745), order='XYZ'> 12 <Vector (0.0000, 0.0000, 1.7462)> <Euler (x=-0.6051, y=-0.0003, z=-0.2745), order='XYZ'> 13 <Vector (0.0000, 0.0000, 1.5514)> <Euler (x=-0.6051, y=-0.0003, z=-0.2745), order='XYZ'> 14 <Vector (-0.0019, -0.0023, 1.3683)> <Euler (x=-0.6003, y=0.0064, z=-0.2701), order='XYZ'> 15 <Vector (-0.0210, -0.0129, 1.3653)> <Euler (x=-0.5499, y=-0.0054, z=-0.2424), order='XYZ'> 16 <Vector (-0.0398, -0.0252, 1.3523)> <Euler (x=-0.4998, y=-0.0101, z=-0.2135), order='XYZ'> 17 <Vector (-0.0575, -0.0389, 1.3295)> <Euler (x=-0.4484, y=-0.0086, z=-0.1837), order='XYZ'> 18 <Vector (-0.0739, -0.0539, 1.2967)> <Euler (x=-0.3944, y=-0.0016, z=-0.1533), order='XYZ'> 19 <Vector (-0.0885, -0.0719, 1.2616)> <Euler (x=-0.3340, y=-0.0000, z=-0.1253), order='XYZ'> 20 <Vector (-0.1019, -0.0923, 1.2204)> <Euler (x=-0.2688, y=0.0000, z=-0.0984), order='XYZ'> 21 <Vector (-0.1143, -0.1144, 1.1706)> <Euler (x=-0.1986, y=0.0000, z=-0.0721), order='XYZ'> 22 <Vector (-0.1259, -0.1380, 1.1108)> <Euler (x=-0.1233, y=0.0000, z=-0.0466), order='XYZ'> 23 <Vector (-0.1366, -0.1629, 1.0403)> <Euler (x=-0.0429, y=-0.0000, z=-0.0216), order='XYZ'> 24 <Vector (-0.1433, -0.1856, 1.0063)> <Euler (x=0.0091, y=0.0072, z=-0.0071), order='XYZ'> 25 <Vector (-0.1443, -0.2039, 1.0366)> <Euler (x=0.0012, y=0.0141, z=-0.0068), order='XYZ'> 26 <Vector (-0.1453, -0.2221, 1.0498)> <Euler (x=-0.0066, y=0.0210, z=-0.0067), order='XYZ'> 27 <Vector (-0.1463, -0.2403, 1.0459)> <Euler (x=-0.0143, y=0.0278, z=-0.0065), order='XYZ'> 28 <Vector (-0.1471, -0.2568, 1.0321)> <Euler (x=-0.0095, y=0.0243, z=-0.0041), order='XYZ'> 29 <Vector (-0.1493, -0.2729, 1.0103)> <Euler (x=0.0003, y=0.0106, z=-0.0009), order='XYZ'>

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .