Select object pattern and then selecting the object I import and object C27389_Part into the scene. I search the part by using bpy.ops.object.select_pattern(pattern=&quot;*_Part&quot;). That's all good, however it is selected (in red outline) and not active (orange), so I cannot do anything with it at this stage. Please help. I have searched and yet cannot solve this simple riddle. bpy.context.scene.objects.active will not do it.
This works after selecting the pattern.
OB = bpy.context.selected_objects[0]
OB.select_set(state=True)
bpy.context.view_layer.objects.active = OB