0

I'm just starting to discover the possibilitys of using csv to create an animation, but i have some trouble with getting the correct values from a CSV.

My problem is that the RZ values all end up as 114 degrees. while I assumed that they would all end up around 2 degrees, what have I done wrong? It seemed to work when I tested it with hard-coded numbers in the script.

I've adapted the script so it works with the standard Cube object in a new file for testing.

this is a small part of the CSV:

X,Y,Z,RX,RY,RZ,FRAME
0,0,0,0,0,1.994,0
1,0,0,0,0,1.996,15
3,0,0,0,0,1.998,30
2,0,0,0,0,1.782,45
4,0,0,0,0,1.999,60
1,0,0,0,0,2.004,75

The script at this moment

# -*- coding: utf-8 -*-

"""
Created on Thu May 16 17:21:32 2019
@author: Me
blender 2.79b
"""
import bpy, csv
import bpy.types
import time
from mathutils import *

fp = "C:/Users/Me/Documents/blender/csv/data.csv"

with open( fp ) as csvfile:
rdr = csv.reader( csvfile )
for i, row in enumerate( rdr ):
    if i == 0: continue # Skip column titles
    X, Y, Z, RX, RY, RZ, FRAME = row[0:7]

    def animate_object( obj, X, Y, Z, RX, RY, RZ, FRAME ):
        obj.location = Vector((float(X),float(Y),float(Z)))
        obj.rotation_mode = 'XYZ'
        obj.rotation_euler = Euler((float(RX),float(RY),float(RZ)))
        obj.keyframe_insert(data_path="location", frame=float(FRAME))
        obj.keyframe_insert(data_path="rotation_euler", frame=float(FRAME))

    cyl = bpy.data.objects["Cube"]

    frame_number = 1
    for frame_number, cp in enumerate(rdr):
        animate_object(cyl, *cp)
user74341
  • 27
  • 6

1 Answers1

0

You are probably using the wrong units, Degrees vs Radians.

You are apparently expecting to enter rotation values in degrees, but Blender expects Radians for Euler Rotations.

See 1.994 Radians = 114 Degrees

enter image description here

Duarte Farrajota Ramos
  • 59,425
  • 39
  • 130
  • 187