Unable to deselect newly added object with Python (Change red selection to orange) - Blender 2.8 I am trying to add an object using from_pydata but am unable to deselect the added item - which is currently outlined in red and then select it so it is outlined in orange - and enter Edit mode.
`mycode
    import bpy, bmesh
    
    me = bpy.data.meshes.new(&quot;Vert&quot; + &quot;Mesh&quot;)
    ob = bpy.data.objects.new(&quot;Vert&quot;, me) 

    me.from_pydata([(1, 2, 5),(0,-1,0),(2,-2,0)],[],[[0,1,2]])
    
    bpy.data.collections['Collection'].objects.link(ob)

    bpy.data.objects[&quot;Vert&quot;].select_set(True)
    bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='MEDIAN')

    bpy.context.active_object.select_set(False) # attempt 1

    bpy.data.objects[&quot;Vert&quot;].select_set(False) # attempt 2

    bpy.ops.object.select_all(action='DESELECT') # attempt 3

    bpy.data.objects[&quot;Vert&quot;].select_set(True)

    bpy.ops.object.mode_set( mode = 'EDIT' )     # Toggle edit mode
    bpy.ops.mesh.select_mode( type = 'FACE' )    # Change to face selection
    bpy.ops.mesh.select_all( action = 'SELECT' )` 

The newly added object is circled in red as opposed to the usual orange. A simple click on anything other than the object &quot;Vert&quot; and select again will make the object orange, as required, but I seem unable to do this via code.
I have tried adding other objects, or selecting other objects in the scene but with no luck.
The Orange you mention is Active state of object,
as other posts described, it is separated from selected object.
The Red ones is selected object. Newly created object in script will be &quot;selected&quot; but not active by default.

If you want to set it as active object:
bpy.context.view_layer.objects.active = some_obj - 2.80 API
For further information: Set active object with python - Blender Stack Exchange