I’ve generated a python script to iterate through a specified set of scenes and select a specified object in that scene using select_pattern() function. I then use this to activate that object and perform some operations on it. When running the script via Run Script button in the Text Editor everything worked as expected, but when I created an Add-on it no longer works as expected. The issue that I am seeing is when I switch the scene then use the select_pattern() function it is not selecting the object. Below is an example code snippet of what I’m doing.
Any help is much appreciated.
# Go through each scene and action that should be animated
for scene in dict:# Set the desired scene
bpy.context.screen.scene = bpy.data.scenes[scene]
for action in dict[scene]:
print('action: ' + action + ' scene: ' + scene)
# Find the vehicle, and select it, needs to be selected to find action
print(bpy.ops.object.select_all(action='DESELECT'))
print(bpy.ops.object.select_pattern(pattern='*Veh*'))
bpy.context.scene.objects.active = bpy.context.selected_objects[0]
# Set the current action
bpy.context.active_object.animation_data.action = bpy.data.actions[action]
# Render the animation
bpy.ops.render.render(animation=True)