5
$\begingroup$

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()?

$\endgroup$

1 Answer 1

6
$\begingroup$

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]
$\endgroup$
2
  • 1
    $\begingroup$ 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? $\endgroup$
    – sambler
    Oct 17, 2016 at 7:45
  • $\begingroup$ @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. $\endgroup$ Oct 17, 2016 at 15:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .