Hi,
I have exported the coordinates for the moving mass of a 3D-pendulum to CSV and imported it with this code:
import csv
import os
import bpy
objekt = bpy.data.objects.new('objekt', None)
bpy.context.scene.objects.link(objekt)
fullpath = '/home/matthieu/Schreibtisch/daten.csv'
with open(fullpath, 'r', newline='') as csvfile:
zeilen = csv.reader(csvfile, delimiter=',')
next(zeilen)
for zeile in zeilen:
f, *tripel = zeile
fnummer = int(f)
punkte = [float(wert) for wert in tripel]
koordinaten = punkte[0:3]
print(koordinaten)
bpy.context.scene.frame_set(fnummer)
objekt.location = koordinaten
objekt.keyframe_insert(data_path="location", index=-1)
when I copy the location of the empty to a sphere I created everything is working. I calculated cylinder which connects the moving sphere with the origin:
import csv
import os
import bpy
objekt = bpy.context.selected_objects[0]
fullpath = '/home/matthieu/Schreibtisch/drehung.csv'
with open(fullpath, 'r', newline='') as csvfile:
zeilen = csv.reader(csvfile, delimiter=',')
next(zeilen)
for zeile in zeilen:
bpy.context.scene.frame_set(int(zeile[0]))
objekt.location = [float(zeile[1]),float(zeile[2]),float(zeile[3])]
objekt.depth=float(zeile[4])
objekt.radius=0.02
objekt.rotation_euler=[float(zeile[5]),float(zeile[6]),float(zeile[7])]
objekt.keyframe_insert(data_path="location", index=-1)
The problem I have is that I can’t change the depth of the cylinder after its creation with Python and I don’t know how to make Python scale the cylinder in respect of its normal to make the cylinder have the length zeile[4].