Skip to content

Instantly share code, notes, and snippets.

@hsaito
Created April 12, 2022 05:35
Show Gist options
  • Save hsaito/eb0f45adc09e39b0da22b598f2374f1f to your computer and use it in GitHub Desktop.
Save hsaito/eb0f45adc09e39b0da22b598f2374f1f to your computer and use it in GitHub Desktop.
import bpy, csv
data = "FILEPATH" # (1)
current_scene = bpy.context.scene
target_object = current_scene.objects["Cube"] # (2)
scale = 100 # (3)
interval = 1 # (4)
current_frame = 1
with open( data, encoding='shift_jis' ) as csvfile: # (5)
reader = csv.reader( csvfile )
for i, row in enumerate( reader ):
if i < 8: continue # (6)
x, y, z = row[0:3]
x = float(x) / scale
y = float(y) / scale
z = float(z) / scale
target_object.location = (x, y, z)
target_object.keyframe_insert(data_path="location", frame=current_frame*interval)
current_frame += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment