Skip to main content
edited tags
Link
added 7 characters in body
Source Link

enter code hereafterafter various failed attempts to make keyframes work to my liking in my first blender-script work I request your help 🥲

So I am working on a Dataviz:

  1. I load Data into Blender and create an object.
  2. Then I transform the object according to the data.
  3. Now I have 4 different years, Year1 - Year4. I want to show each transformation, for each Year with keyframes (one keyframe shows one year location, scale transformation)
  4. and all of the keyframes of the 150 country-Objects should start and end at the same time.

...But the mechanics of the for-loop are laughing at my face - I got everything working except for the keyframes which drives me mad 🤪 so If I use an offset the transformations for each object are working perfectly, but they don't start at the same time - if I try and use iteration, I have neat keyframes, but no animation (I will only show Year4). How do I get out of this Mess? 😓

See the code for yourselfthe Iteration-version on github: https://github.com/SaraHeitz/blenderpython

Version with offset: https://www.youtube.com/watch?v=QTyYj4ZKNBA enter image description here enter image description here

Version with iteration: enter image description here enter image description here

So in short I would love for this Dataviz to animate the country for each year, and set a keyframe for the according values, like the youtube animation, but start and end at the same time for every object: https://www.youtube.com/watch?v=QTyYj4ZKNBA

enter code hereafter various failed attempts to make keyframes work to my liking in my first blender-script work I request your help 🥲

So I am working on a Dataviz:

  1. I load Data into Blender and create an object.
  2. Then I transform the object according to the data.
  3. Now I have 4 different years, Year1 - Year4. I want to show each transformation, for each Year with keyframes (one keyframe shows one year location, scale transformation)
  4. and all of the keyframes of the 150 country-Objects should start and end at the same time.

...But the mechanics of the for-loop are laughing at my face - I got everything working except for the keyframes which drives me mad 🤪 so If I use an offset the transformations for each object are working perfectly, but they don't start at the same time - if I try and use iteration, I have neat keyframes, but no animation (I will only show Year4). How do I get out of this Mess? 😓

See for yourself on github: https://github.com/SaraHeitz/blenderpython

Version with offset: https://www.youtube.com/watch?v=QTyYj4ZKNBA enter image description here enter image description here

Version with iteration: enter image description here enter image description here

So in short I would love for this Dataviz to animate the country for each year, and set a keyframe for the according values, like the youtube animation, but start and end at the same time for every object: https://www.youtube.com/watch?v=QTyYj4ZKNBA

after various failed attempts to make keyframes work to my liking in my first blender-script work I request your help 🥲

So I am working on a Dataviz:

  1. I load Data into Blender and create an object.
  2. Then I transform the object according to the data.
  3. Now I have 4 different years, Year1 - Year4. I want to show each transformation, for each Year with keyframes (one keyframe shows one year location, scale transformation)
  4. and all of the keyframes of the 150 country-Objects should start and end at the same time.

...But the mechanics of the for-loop are laughing at my face - I got everything working except for the keyframes which drives me mad 🤪 so If I use an offset the transformations for each object are working perfectly, but they don't start at the same time - if I try and use iteration, I have neat keyframes, but no animation (I will only show Year4). How do I get out of this Mess? 😓

See the code for the Iteration-version on github: https://github.com/SaraHeitz/blenderpython

Version with offset: https://www.youtube.com/watch?v=QTyYj4ZKNBA enter image description here enter image description here

Version with iteration: enter image description here enter image description here

So in short I would love for this Dataviz to animate the country for each year, and set a keyframe for the according values, like the youtube animation, but start and end at the same time for every object: https://www.youtube.com/watch?v=QTyYj4ZKNBA

deleted 1319 characters in body
Source Link

Version with offset: https://www.youtube.com/watch?v=QTyYj4ZKNBA [![enter image description here][1]][1]enter image description here [![enter image description here][2]][2]enter image description here

Version with iteration: [![enter image description here][3]][3]enter image description here [![enter image description here][4]][4]enter image description here

So in short I would love for this version ofDataviz to animate the country for each year, and set a keyframe for the according values, like the youtube animation, wouldbut start and end at the same time for every object: https://www.youtube.com/watch?v=QTyYj4ZKNBA

this is a reduced version of the whole code with iteration:

scn = bpy.context.scene scn.frame_start = 1 current_frame = 0 #---DATA DIMENSIONS for var_l in read_list: cname = var_l[0] #150 Countries year = float(var_l[5]) #Year0, Year1, Year2, Year3, Year4 x = float(var_l[5]) #Value1 y = float(var_l[5]) #Value2 z = float(var_l[5]) #Value3 #---CREATE NAMED BASE if year == Year0: cylinder = bpy.ops.mesh.primitive_cylinder_add(enter_editmode=False, align='WORLD', location=(1, 1, 1), scale=(1, 1, 1)) for cylinder in bpy.context.selected_objects: cylinder.name = cname #---LOOP YEARS, SHOW VALUES (HOPEFULLY) else : my_cylinder = bpy.data.objects[cname] test = cname == my_cylinder.name if test: for iteration, item in enumerate(var_l[5]): cylinder.location[0] = x cylinder.location[5] = y cylinder.location[5] = z cylinder.scale = (0.05, 0.05, z) ita = iteration*10 cylinder.keyframe_insert(data_path = "location", frame = scn.frame_start + ita) cylinder.keyframe_insert(data_path = "scale", frame = scn.frame_start + ita ) scn.frame_end = ita``` [1]: https://i.sstatic.net/kMxKx.png [2]: https://i.sstatic.net/OLoxw.png [3]: https://i.sstatic.net/0JnVu.png [4]: https://i.sstatic.net/YCKbv.png [5]: https://i.sstatic.net/LerRf.png 

Version with offset: https://www.youtube.com/watch?v=QTyYj4ZKNBA [![enter image description here][1]][1] [![enter image description here][2]][2]

Version with iteration: [![enter image description here][3]][3] [![enter image description here][4]][4]

So in short I would love for this version of the youtube animation, would start and end at the same time for every object: https://www.youtube.com/watch?v=QTyYj4ZKNBA

this is a reduced version of the whole code with iteration:

scn = bpy.context.scene scn.frame_start = 1 current_frame = 0 #---DATA DIMENSIONS for var_l in read_list: cname = var_l[0] #150 Countries year = float(var_l[5]) #Year0, Year1, Year2, Year3, Year4 x = float(var_l[5]) #Value1 y = float(var_l[5]) #Value2 z = float(var_l[5]) #Value3 #---CREATE NAMED BASE if year == Year0: cylinder = bpy.ops.mesh.primitive_cylinder_add(enter_editmode=False, align='WORLD', location=(1, 1, 1), scale=(1, 1, 1)) for cylinder in bpy.context.selected_objects: cylinder.name = cname #---LOOP YEARS, SHOW VALUES (HOPEFULLY) else : my_cylinder = bpy.data.objects[cname] test = cname == my_cylinder.name if test: for iteration, item in enumerate(var_l[5]): cylinder.location[0] = x cylinder.location[5] = y cylinder.location[5] = z cylinder.scale = (0.05, 0.05, z) ita = iteration*10 cylinder.keyframe_insert(data_path = "location", frame = scn.frame_start + ita) cylinder.keyframe_insert(data_path = "scale", frame = scn.frame_start + ita ) scn.frame_end = ita``` [1]: https://i.sstatic.net/kMxKx.png [2]: https://i.sstatic.net/OLoxw.png [3]: https://i.sstatic.net/0JnVu.png [4]: https://i.sstatic.net/YCKbv.png [5]: https://i.sstatic.net/LerRf.png 

Version with offset: https://www.youtube.com/watch?v=QTyYj4ZKNBA enter image description here enter image description here

Version with iteration: enter image description here enter image description here

So in short I would love for this Dataviz to animate the country for each year, and set a keyframe for the according values, like the youtube animation, but start and end at the same time for every object: https://www.youtube.com/watch?v=QTyYj4ZKNBA

added 745 characters in body
Source Link
Loading
Fixed typos
Source Link
quellenform
  • 41.8k
  • 10
  • 68
  • 161
Loading
Source Link
Loading