0
$\begingroup$

enter image description here

i just want to select this object, the suzanne with the active origin in red,'is is she active or just the last selected?

i dont know the code, and i dont know also how to find this kind of code, ive been searching for two hours... any tips how to find the desired action within blender in this kind of cases?

thanks

$\endgroup$
6
  • 1
    $\begingroup$ bpy.context.active_object related $\endgroup$
    – Ratt
    Commented Dec 5, 2018 at 4:57
  • $\begingroup$ blender.stackexchange.com/questions/38618/… $\endgroup$ Commented Dec 5, 2018 at 6:44
  • $\begingroup$ Please show the entire screen with footers so we all the information needed $\endgroup$ Commented Dec 5, 2018 at 6:46
  • $\begingroup$ bpy.context.active_object dont work for me on 2.8 $\endgroup$
    – Fox
    Commented Dec 5, 2018 at 17:15
  • $\begingroup$ i also tried bpy.context.active_object.select = True bpy.context.scene.objects.active = bpy.context.active_object i got error and i dont know what im doing im just trying to copy code that work on the proposed lonk, but it doesnt result in anything $\endgroup$
    – Fox
    Commented Dec 5, 2018 at 17:20

1 Answer 1

1
$\begingroup$

You can usually retrieve the active object with: bpy.context.active_object or bpy.context.object

If you need to take the view layer into account: bpy.context.view_layer.objects.active

Chances are your view layer is already set, but if the view layer needs to be set, you can first do: bpy.context.window.view_layer = view_layer

[source]

To make sure the active object is also a selected object, you can do this:

import bpy
my_object = bpy.context.view_layer.objects.active # assign variable
my_object.select_set(True) # select the object

Setting an object as active is a similar process. See this answer to learn about that.

Many operations require both an active object and at least one additional selected object.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .