[Tutor] Specifying the selected object number in Blender
Peter Otten
__peter__ at web.de
Wed Aug 6 02:15:19 CEST 2014
Marcus Mravik wrote:
> I am trying to specify a number based on what the selected object number
> in the scene is.
>
> import bpy
>
> for obj in bpy.context.selected_objects:
>
> bpy.context.scene.objects.active = obj
>
> bpy.ops.graph.sound_bake(filepath="C:\\Users\\Marcus\\Music\\Don't
> Just
> Stand There (Instrumental).mp3", low=50*(((WHERE OBJECT NUMBER GOES))),
> high=100+50*(((WHERE OBJECT NUMBER GOES)))
>
> (((WHERE THE OBJECT NUMBER GOES))) is not part of the script, it's just
> where my question comes from.
>
> My overall goal is to create a Music Visualizer with Blender and I am
> trying to automate the selection of the object, applying the variable that
> goes up by 50 each time, starting with 0 for the low freq and 50 for the
> high freq. And ending with 7950 low and 8000 high.
If "object number" is not a blender-specific term and just 0 for the first,
1 for the second, and 2 for the third object in selected_objects:
for index, obj, in enumerate(bpy.context.selected_objects):
bpy.context.scene.objects.active = obj
bpy.ops.graph.sound_bake(
filepath="C:\\Users\\Marcus\\Music\\Don't "
"Just Stand There (Instrumental).mp3",
low = index * 50,
high = (index + 1) * 50)
More information about the Tutor
mailing list