# More performant way of creating x amount of objects (100's)

I'm working on taking keyframe data such as

y_rotation_values = "0:(0),40:(1),80:(0.5),120:(0),160:(-1),200:(-0.7),240:(0.5),300:(0)"
z_rotation_values = "0:(0)"


frame#:(Euler angle), ...

and computing the Euler angle differences between each set of frames then generating a cube at each point based upon the last cubes local position. With more than a few 100 cubes it takes a while to create and when testing something over 1200 as far as frames of animation with a cube at each one blender almost crashed. Is there a more performant way to handle so many objects?

example screen shot [![enter image description here][1]][1]

Things I have tried but failed due to my lack of blender coding.

Instead of a cube at each point in space, create a bezier curve at those points and attach 1 cube that has keyframes, so I can just hit play and see the cube move along the path.

Try to only create every Nth cube but keep it generating the path so I have less cubes.

I prefer the spline method and I have tried various attempts w/o luck..

Example code that takes a dic of values like this.. (x,y,z)

{0: [0.0, 0.0, 0.0], 1: [0.025, 0.0125, 0.0], 2: [0.05, 0.025, 0.0], 3: [0.07500000000000001, 0.037500000000000006, 0.0], 4: [0.1, 0.05, 0.0], 5: [0.125, 0.0625, 0.0], 6: [0.15000000000000002, 0.07500000000000001, 0.0], 7: [0.17500000000000002, 0.08750000000000001, 0.0], 8: [0.2, 0.1, 0.0], 9: [0.225, 0.1125, 0.0], 10: [0.25, 0.125, 0.0], 11: [0.275, 0.1375, 0.0], 12: [0.30000000000000004, 0.15000000000000002, 0.0], 13: [0.325, 0.1625, 0.0], 14: [0.35000000000000003, 0.17500000000000002, 0.0], 15: [0.375, 0.1875, 0.0], 16: [0.4, 0.2, 0.0]}

passes it though this function.. excuse my lack of blender coding..

# the LOCAL origin of the previous cube.
# Currently using the Y axis in Blender to display the cubes
# This also creates animation keyframes that you can play back from the layout / timeline
# creating a cube at the origin
cube = bpy.context.object
bpy.ops.object.transform_apply(location=True, rotation=True, scale=True)

# creating a list to store all created cubes
cubes = [cube]

# Set the maximum number of keyframes
bpy.context.scene.frame_end = len(data_dict)

# iterating through data and creating cubes
for i, rot in enumerate(data_dict.values()):
if i % interval == 0:
# duplicating the last cube and applying rotation and translation
bpy.context.object.rotation_euler = rot
cube = bpy.context.object
cubes.append(cube)

cube.keyframe_insert(data_path="location", frame=i+1, group="LocRot")
cube.keyframe_insert(data_path="rotation_euler", frame=i+1, group="LocRot")

# Print out location and rotation
print("Cube {}: Location={}, Rotation={}".format(i, cube.location, cube.rotation_euler))
return cubes

# make this happen!
create_cubes_from_data1(xyz_dict, 1.5)

thoughts, help?

[1]: https://i.stack.imgur.com/9XpLb.png
`