6
$\begingroup$

Let's say I want to create a new bone constraint in a script. Blender then tells me that it wants to know which type of constraint I want to create.

Can I print a list of all possible types? I know I could reverse engineer the names by creating the constraints and reading the types, but I'd like to have a more general solution.

So, is there something like print(dir()) that does the job?

$\endgroup$
4
$\begingroup$

To answer your question, you can print a list like this:

print(bpy.types.Constraint.bl_rna.properties["type"].enum_items.keys())

But in this case I'd suggest to use Blenders documentation.

Note that this is Blender specific, Python doesn't provide a way to list possible valid values for an attribute.

$\endgroup$
4
$\begingroup$

If all you need is an enumeration of available constraints, it's listed in bpy.types.Constraint API documentation.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.