Driving from a custom property.
Further to my comment I thought I would explain how to use one custom property, per club, in this case "points" to drive other objects. Consider this more an exercise in setting up and organizing.
I've used a script below to create the bars and badges, as I find that easier than using the UI.
Quite simply it's a cube as the bar, a sphere as the badge, with origins on their LHS, parented to an empty. The empty has a custom property "points". The scale of the bar, and the location of the badge are driven by the points property of empty. (self.parent["points"]
)
For convenience added a "League" empty to be able to transform the whole lot.
import bpy
from mathutils import Vector
context = bpy.context
scene = context.scene
def add_club(name, loc):
bpy.ops.object.empty_add(radius=2, location=loc)
mt = context.object
mt.name = name
bpy.ops.mesh.primitive_cube_add(location=(0, 0, 0))
bar = context.object
bar.name = "%s_bar" % name
bpy.ops.mesh.primitive_uv_sphere_add(location=(0, 0, 0))
badge = context.object
badge.name = "%s_badge" % name
for o in [bar, badge]:
o.parent = mt
for v in o.data.vertices:
v.co.x += 1
mt["points"] = 1
# add drivers to bar and badge
d = bar.driver_add("scale", 0)
d.driver.use_self = True
d.driver.expression = 'self.parent["points"]'
d = badge.driver_add("location", 0)
d.driver.use_self = True
d.driver.expression = '%4.2f * self.parent["points"]' % bar.dimensions.x
return mt
clubs = {"Geelong" : [2, 4, 10],
"Richmond" : [2, 3],
"Collingwood" : [0],
"Essendon" : [2, 4, 5],
"Fremantle" : [1, 2],
"Sydney" : [4],
"Brisbane" : [2]}
loc = Vector()
bpy.ops.object.empty_add(radius=4)
handle = context.object
handle.name = "League"
for name, data in clubs.items():
club = add_club(name, loc)
club.parent = handle
# keyframe data on points
club["points"] = 0.0 # make int for steppy
club.keyframe_insert('["points"]', frame=0)
frame_step = 20
for i, pt in enumerate(data):
club["points"] = float(pt)
club.keyframe_insert('["points"]', frame=(i + 1) * frame_step)
loc.z -= 2.2
scene.objects.active = handle
handle.select = True
Result of running the script. A club can be selected simply from the outliner