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’)
bpy.ops.object.select_all(action=“DESELECT”)
This seems to deselect all ob but not the active ob !
bpy.context.scene.update()
objname1=“Cube”
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 =’,obj.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
CoDEmanX
(CoDEmanX)
June 26, 2014, 10:57pm
2
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 = bpy.data.objects['Cube']
ob_2 = bpy.data.objects['Plane']
bpy.ops.object.select_all(action='DESELECT')
ob_1.select = True
ob_2.select = True
bpy.context.scene.objects.active = ob_2
bpy.ops.object.join()
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 !
thanks
CoDEmanX
(CoDEmanX)
June 27, 2014, 7:35am
4
an RMB-click in UI does two things:
selects the object
makes that object active
so you need to do the same with python.
Override:
import bpy
ob_1 = bpy.data.objects["Circle"]
ob_2 = bpy.data.objects["Circle.001"]
ctx = bpy.context.copy()
ctx['selected_editable_bases'] = [bpy.context.scene.object_bases[ob.name] for ob in (ob_1, ob_2)]
ctx['active_object'] = ob_2
bpy.ops.object.join(ctx)
but also when you do a select with ob name
this is not equivalent to click RMB to select !
ob_1 = bpy.data.objects[“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