Selecting Object

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
Akos
Posts: 0
Joined: Wed Jul 10, 2013 4:08 pm

Selecting Object

Post by Akos » Thu Jul 18, 2013 2:10 pm

i need to change the corrent selected object in the phyton code. Basecally i want to get the same result as clicking with the right click of the mouse of an object (selecting it). By this the

Code: Select all

bpy.context.object 
will be changed. I cant change directly the bpy.context.object because it is a readonly one.

Help me please :(

orimouse
Posts: 0
Joined: Wed Mar 20, 2013 1:35 am

Post by orimouse » Thu Jul 18, 2013 6:00 pm

It's quite difficult to give you a precise answer without more information, but you can simply define a variable such as :

Code: Select all

obj = bpy.context.object
and put it in each function or class where your current active object may change.

CoDEmanX
Posts: 0
Joined: Sun Apr 05, 2009 7:42 pm
Location: Germany

Post by CoDEmanX » Fri Jul 19, 2013 12:31 am

This reproduces the right-click behavior

Code: Select all

# assuming, "ob" is an object reference
bpy.ops.object.select_all(action='DESELECT')
ob.select = True
bpy.context.scene.objects.active = ob
I'm sitting, waiting, wishing, building Blender in superstition...

Akos
Posts: 0
Joined: Wed Jul 10, 2013 4:08 pm

Post by Akos » Fri Jul 19, 2013 9:29 am

Thank you a lot guys, if worked out the bpy.context.scene.objects.active

Akos

Post Reply