I am looking for class types of blender property objects.
I am looping over some properties in a scene and want to operate on them when they are bpy.types.CollectionProperty
.
My custom property is for example stored in bpy.data.scene[0].my_custom_collection_prop
Here is some pseudo code:
for key,value in bpy.data.scene[0].items():
prop = getattr(bpy.data.scene[0],key)
if type(prop) == bpy.types.CollectionProperty:
do something
type(prop)
gives me <class 'bpy_prop_collection_idprop'>
which is not bpy.types.CollectionProperty
. So I don't know how to compare both.
Here is an example showing whats intended, it runs but doesn't find the type:
import bpy
from bpy.props import StringProperty, CollectionProperty
class MyCollectionProperty(bpy.types.PropertyGroup):
name = StringProperty(default="")
bpy.utils.register_class(MyCollectionProperty)
bpy.types.Scene.my_collection_prop = CollectionProperty(
type=MyCollectionProperty)
scene = bpy.data.scenes[0]
for attr in dir(scene):
prop = getattr(scene, attr, None)
if prop is not None:
if type(prop) == bpy.types.CollectionProperty:
print(prop)