List bpy.types in a scene including empties In the example shown below, all bpy.types are found, except that for the empty. Is it possible to add code to find the bpy.type for the empty as well? This is Blender 2.81a.



The code is listed below and the .blend file can be downloaded here.

import bpy,os

# Clean the terminal window, on linux/mac use 'clear', on windows use 'cls'
os.system('cls')

for obj in bpy.data.objects:

    print("\nObject name:",obj.name)

    if type(obj.data) == bpy.types.Mesh:
        print("bpy.type: MESH")

    if type(obj.data) == bpy.types.PointLight:
        print("bpy.type: LIGHT")

    if type(obj.data) == bpy.types.Camera:
        print("bpy.type: Camera")

#    How to find the Empty? This code does not work:
#    if type(obj.data) == bpy.types.Empty: 
#        print("Type: Empty")
I guess, you just want to execute something based on the actual type of object while running through a list of objects in the scene. In this case, better use the type attribute of each object, which returns (as you probably guess) the type per object so no need to compare against RNA types:

&gt;&gt;&gt; C.object
bpy.data.objects['Empty']

&gt;&gt;&gt; C.object.type
'EMPTY'


Test all objects of the collection in context (active collection):

import bpy

C = bpy.context

for obj in C.collection.objects:
    # Check for geometry type
    if obj.type not in ('EMPTY', 'CAMERA', 'LIGHT'):
        print ("Geometry object:", obj.name)
    # Check for empty
    elif obj.type == 'EMPTY':
        print ("Empty object:", obj.name)
        # Print the type
        print ("Draw type:", obj.empty_display_type)


API: https://docs.blender.org/api/current/bpy.types.Object.html?highlight=type#bpy.types.Object.type 

All types of objects for reference: 'MESH', 'CURVE', 'SURFACE', 'META', 'FONT', 'ARMATURE', 'LATTICE', 'EMPTY', 'GPENCIL', 'CAMERA', 'LIGHT', 'SPEAKER', 'LIGHT_PROBE'