Need your Help:How can I make a object with python active??

Hello…

I started to learn python and I made/make a little script, but there is one problem:

I made a script, which adds a new curve, extrudes it and add a hook to the new handle of the curve…
I will select the new empty, but I don’t know how to make this with python.
It have to be active, because I will bake soundcurves to the location keyframe of the empty…

Here is the script that I hava already ritten:

http://www.pasteall.org/47268/python

Maybe some of you python experienced guys can help me.

Thanks Mic Lac

Not a pro myself, but maybe I can be of help. I am using something like the following code to select an object. In this example single_object has to point to the object you want to select (e.g. via single_object = bpy.data.objects[‘your_object’] or a loop):

bpy.ops.object.select_all(action=‘DESELECT’)
bpy.context.scene.objects.active = single_object
single_object.select = True

Great!!

Do you think it’s possible do make something like:

import bpy

x=0
y=0

single_object = bpy.data.objects[‘Empty.0xy’]

bpy.ops.object.select_all(action=‘DESELECT’)
bpy.context.scene.objects.active = single_object
single_object.select = True

y +=1

if y==9:
x +=1
y=0

I know the script isn’t right yet, but I just wont to show you my idea…
But the problem is, that I can not type Empty.0xy, because I have then errors…Do you know how I have to type it, that it works??

Select Empty.000 to Empty.019:

obs = bpy.context.scene.objects

for i in range(20):
    ob = obs.get("Empty.%03i" % i)
    if ob is not None:
        ob.select = True

Sorry for late answer.
I made a mix from bouth of your “scripts”.
Now it works.
Thanks a lot!
I will modify the script a little bit and post it here…