I cannot rotate objects with python script in animation So, i have an object, i have list of data, the translation nmovement is completely fine, but the rotational movement is not. It takes the last piece of data from the loop and sets the rotation according to that. I am at my wits end.
It is not datas fault. No matter what sequence i put there, it doesnt do anything. I put variable &quot;line_count&quot; for demonstration that it does nothing :D. It jut always rotates according to the last one.
code:
from math import *
from mathutils import *
from math import radians
import csv

myobj = bpy.data.objects['Cube']

# Clear all previous animation data
myobj.animation_data_clear()

# set first and last frame index
total_time = 50 # Animation should be 2*pi seconds long
fps = 24 # Frames per second (fps)
bpy.context.scene.frame_start = 0
bpy.context.scene.frame_end = 1001
myobj.location.x = 0
myobj.location.y = 0
myobj.location.z = 0
# loop of frames and insert keyframes every 10th frame

with open('C:/Users/ADMIN/Desktop/School/Advanced control/Quadcopter/Blah/href_input_h.csv') as csv_file:
    csv_reader = csv.reader(csv_file, delimiter=',')
    line_count = 0
    for row in csv_reader:
        bpy.context.scene.frame_set(line_count)
        myobj.location.x = 1
        myobj.location.y = 1
        myobj.location.z = 1
        myobj.rotation_euler.x = line_count
        

        # Insert new keyframe for &quot;location&quot; like this
        myobj.keyframe_insert(data_path=&quot;location&quot;)
        line_count += 1
    print(f'Processed {line_count} lines.') ```
Adding a keyframe for the rotation part was missing.
Just add:
myobj.keyframe_insert(data_path=&quot;rotation_euler&quot;)