rarebit
(rarebit)
1
Here’s an example:
import bpy
obj = bpy.context.active_object
bpy.ops.object.duplicate()
obj.select=False
# Do something to currently selected object
bpy.ops.object.delete()
obj.select=True
Even though i’ve reselected the original object, it’s not actually selected. Which can be demonstrated by appending this to the previous.
obj2 = bpy.context.active_object
print("name:",obj2)
Which will print ‘None’!
Q. How to make it the active object again?
Now, this technically works:
obj2=bpy.context.scene.objects[obj.name]
print("name:",obj2.name)
But, it still leaves the object dark orange (not light orange) and a panels poll function won’t recognise it as a singly selected object (of type).
Any solutions?
well this works fine
# Duplicate object
bpy.context.scene.objects.active = bpy.context.scene.objects["Fluo1"]
print (' object name being moved =',bpy.context.scene.objects.active.name )
bpy.ops.object.duplicate_move()
obj_act = bpy.context.active_object
obj_act.location.y += -spaceing
obj_act.name="Fluo2"
bpy.context.scene.objects.active = bpy.context.scene.objects["Fluo2"]
print (' object name being moved =',bpy.context.scene.objects.active.name )
bpy.ops.object.duplicate_move()
obj_act = bpy.context.active_object
obj_act.location.y += -spaceing
obj_act.name="Fluo3"
bpy.context.scene.objects.active = bpy.context.scene.objects["Fluo3"]
print (' object name being moved =',bpy.context.scene.objects.active.name )
bpy.ops.object.duplicate_move()
obj_act = bpy.context.active_object
obj_act.location.y += -spaceing
obj_act.name="Fluo4"
obmat2=bpy.context.scene.objects.active = bpy.context.scene.objects["Fluobox24"]
does it help
happy 2.5
rarebit
(rarebit)
3
It does… many thanks!
import bpy
obj = bpy.context.active_object
name=obj.name
bpy.ops.object.duplicate()
obj.select=False
# Do something to currently selected object
bpy.ops.object.delete()
obj.select=True
bpy.context.scene.objects.active=obj