I am working on animating a data visualization project (see attached) in Blender using Python for a movie. I am creating wedges of different radii around a circle, but I would like to animate the creation and deletion of these wedges. In my limited experience in Blender, I am thinking I want to create a mesh wedge, move the key frame a couple frames, then create the next one and so on. Then when the creation is done, I want to wait a few seconds and then delete the mesh wedges one at a time changing the keyframe after each deletion. Repeat x number of times. This is not working for me. I am able to iterate through the wedges, the deletions, and the subsequent creation of a new set of wedges, but I can’t seem to make this happen with delays in each step. Does anyone have any suggestions or ideas that could point me in the right direction?
Could you provide a storyboard? I like your idea. Still, it’s hard to figure out what you wanna do exactly. Should the wedges pop in sorted already or should all wedges rotate a bit and make some room between the largest and the smallest? Are the wedges there already and you just wanna let them grow? Or how exactly is the creation and deletion done? Maybe a trick would be to have the wedges there and just scale them to zero if you want to let them disappear. Do you have some references in mind that you could post here?
You probably should work with custom properties and parent your wedges to an empty that has maybe a custom property to control the amount of wedges and a custom property where your custom driver function is called, which will adjust all your wedges while only a few of them are animated at a time.
Maybe somebody can help you better with bones & constraints. But I think we would appreciate a story board anyway.
See above images. I am trying to step by step delete the largest wedge (and each smaller pink and blue wedge on top of the large wedge) until there are none left - mimicing a counter-clockwise spiral motion. Once there are none left, I will recreate the “jagged circle” creating new wedges from new data one wedge at a time.
The deletion is done as below, written one at a time in hopes there is a way to animate this:
for i in range(1, number_wedge_meshes):
obj = bpy.data.objects["wedge%s"%i]
bpy.context.scene.objects.unlink(obj)
bpy.data.objects.remove(obj)
Attachments
Hi,
You could do this with a frame change handler. If you want it as an effect that happens on a single frame for the UI and not animating then do it via a modal timer operator.
Put in a couple of ways of choosing. If the rotation in degrees equals the frame number minus one then do something… or add a custom property life to the wedge and do something if wedge[“life”] = frame.
I’d suggest moving to a hidden layer or hiding / scaling them rather than removing and unlinking each time. . not that it matters greatly.
import bpy
from math import degrees
def remove_wedges(scene):
frame = scene.frame_current
''' wedges whose z rotation in degrees matches frame number
'''
wedges = [wedge for wedge in scene.objects
if wedge.name.startswith("wedge")
and int(degrees(wedge.rotation_euler.z)) == frame-1]
'''
#this selects wedges that have a custom prop "life" which
#matches the frame number
wedges = [wedge for wedge in scene.objects
if wedge.name.startswith("wedge")
and "life" in wedge.keys()
and wedge["life"] == frame]
'''
for wedge in wedges:
print("remove wedge %s at frame %d" % (wedge.name, frame))
# remove them or whatever here
# code to remove the handler if already there.
fs = [f for f in bpy.app.handlers.frame_change_pre
if f.__name__.startswith("remove_wedges")]
for f in fs:
bpy.app.handlers.frame_change_pre.remove(f)
bpy.app.handlers.frame_change_pre.append(remove_wedges)
Thanks.
I actually just saved the image as a .FBX and loaded into Unity…this way I was able to embed into a webpage and have users zoom around in it.
If you are interested: http://www.webdevref.com/blog/index.cfm/2012/10/31/Hubway-Data-Visualization-Challenge
Thanks again.
Chris