Re: csv>python>blender

Posté par Cdric le 18/3/2021 11:15:03
j'y suis finalement parvenu
apparemment, le type de fichier devait Ítre "AVI_RAW"
ce qui donne :

import bpy
import csv
from math import pi #useful for text and camera rotation_euler
#create material
material_basic = "Basic")
material_basic.use_nodes = True
principled_node = material_basic.node_tree.nodes.get('Principled BSDF')
principled_node.inputs[17].default_value = (1,1,1,1)

def event_text(event):
    ob = bpy.context.object      
    curve =
    curve.body = "%s"%event
#define scene
scn = bpy.context.scene
# create the first camera
cam1 ="Camera 1")
cam1.lens = 18
# create the first camera object
cam_obj1 ="Camera 1", cam1)
cam_obj1.rotation_euler = (pi*90/180, 0, 0) = cam_obj1

#extract datas from csv file :
file = '\\Users\essai.csv'
#make the loop 
with open( file, 'r' ) as f:
    reader = csv.reader(f, delimiter=',')
    for row in reader:
        x, y, z, event = row[0], row[1], row[2], row[3]
        cam_obj1.location = (float(x),float(y)-3,float(z))
        cam_obj1.keyframe_insert(data_path=("location"), frame=((reader.line_num)-1)*120)
        cam_obj1.keyframe_insert(data_path=("location"), frame=((reader.line_num)-1)*120+120)
        print (reader.line_num)
        #creer les blocs textes 
bpy.context.scene.render.filepath = '\\Users\essai'
bpy.context.scene.render.image_settings.file_format = "AVI_RAW"
bpy.ops.render.render(animation = True)

Cette contribution était de :