select or unselect ob ?

trying to select 2 ob to join

but might be some scene update not done somehow

if I use something like this and I have some selected ob it does not work

print (‘De select ob’)

This seems to deselect all ob but not the active ob !


print (‘select the Cube 1 ob’)
bpy.ops.object.select_pattern(extend=True, pattern=objname1, case_sensitive=False)

print (‘objname1 =’,objname1)
obj = bpy.context.active_object
print (‘1 ob active ob name =’,

print ()

for doing the join you need to have the last selected ob as the active ob

I thought that the last selected one was the active ob -but may be wrong

thanks for any help

the active object is the active object, it is not directly related to the concept of selection - although in UI, it is handled to be the last selected one.

ob_1 =['Cube']
ob_2 =['Plane']
bpy.ops.object.select_all(action='DESELECT') = True = True = ob_2

Or use an override to leave selection unchanged.

ok I also found late yesterday night this active command!

join use the active object so needed to change active ob before doing the join command !

what do you mean by the override method ?

is there like a command to make active ob = null may be?

and when you make a new primitive it becomes the active ob = last selected ob
then you can do operations on it without having to re select it !


an RMB-click in UI does two things:

  • selects the object
  • makes that object active

so you need to do the same with python.


import bpy

ob_1 =["Circle"]
ob_2 =["Circle.001"]

ctx = bpy.context.copy()

ctx['selected_editable_bases'] = [bpy.context.scene.object_bases[] for ob in (ob_1, ob_2)]
ctx['active_object'] = ob_2


but also when you do a select with ob name
this is not equivalent to click RMB to select !

ob_1 =[“Circle”]

this will add to the selection list but wont make it the active ob!

and I think it is what created so much problem and mix things up!

but thanks for clarifying this

happy bl