5

How can I get a list of modifiers for Blender in Python? I know about bpy.types.SomeModifier(), but isn't there something to use to get a list of all of the possible modifiers?

  • I know the list isn't too long to make by hand, but I really don't want to hardcode it if I don't have to.

Is this possible to list out with bpy.types.Modifier()?

JakeD
  • 8,467
  • 2
  • 30
  • 73

1 Answers1

6

bpy.types.Modifier.bl_rna.properties['type'].enum_items contains a list of all modifier types.

To get a list of their Python identifiers you can do:

modifiers = []

for modifier in bpy.types.Modifier.bl_rna.properties['type'].enum_items:

    modifiers.append(modifier.identifier)

Or, more Pythonically:

modifiers = [modifier.identifier for modifier in bpy.types.Modifier.bl_rna.properties['type'].enum_items]
Ray Mairlot
  • 29,192
  • 11
  • 103
  • 125
  • 1
    But can we separate the list based on what objects they can be used with? Or is that a test to do when trying to create a modifier? – sambler Oct 17 '16 at 07:45
  • @sambler I'm not sure, there could be a property somewhere which lists which objects it works on. You may have to look at the source code to see how the different modifiers lists are created (curve, object etc) to give a clue as to whether there is a property that does this or whether it's done more manually. I might look into this when I get time. – Ray Mairlot Oct 17 '16 at 15:17