Skip to content

Instantly share code, notes, and snippets.

@D0tty
Created November 2, 2020 19:55
Show Gist options
  • Save D0tty/61bdf346b8cac3ace4928ec5f1d24b5e to your computer and use it in GitHub Desktop.
Save D0tty/61bdf346b8cac3ace4928ec5f1d24b5e to your computer and use it in GitHub Desktop.
machin.py iteration animation
import bpy
import bmesh
import csv
import ntpath
from mathutils import Vector
from bpy_extras.object_utils import object_data_add
path = '/home/ortes/GISTRE/GPGPU/icp-gpgpu/cmake-build-release/'
#path = '/home/ortes/GISTRE/GPGPU/icp-gpgpu/data_students/'
def instantiate(filename):
file = open(path + filename)
inFile = csv.reader(file, delimiter=',', quotechar='"')
inFile.__next__()
new_mesh = bpy.data.meshes.new(filename)
vertices = []
for row in inFile:
vertices.append((float(row[0]), float(row[1]), float(row[2])))
file.close()
new_mesh.from_pydata(vertices, [], [])
new_mesh.update()
try:
bpy.data.objects.remove(bpy.data.objects[filename])
except:
pass
object = bpy.data.objects.new(filename, new_mesh)
bpy.data.collections['Collection'].objects.link(object)
return object
#instantiate('bun270.txt')
i = 0
while True:
object = instantiate('bun' + str(i) + '.txt')
object.keyframe_insert('hide_viewport', -1, i)
object.hide_viewport = True
object.keyframe_insert('hide_viewport', -1, i + 1)
object.keyframe_insert('hide_viewport', -1, i - 1)
i = i + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment