How to get all possible EnumProperty values for function parameters
When passing an EnumProperty value to the function parameters, just like with direct assignment, we must always specify the value from the constant list exactly, otherwise, Blender will throw an error.
For example, specifying an icon for a button in the UI we pass the text identifier to the "icon" parameter of the "layout.operator" function.
self.layout.operator(
"mesh.primitive_cube_add",
icon='ICON',
text=""
)
If it is not correct, Blender throws an error:
TypeError: UILayout.operator(): error with keyword argument "icon" - enum "ICON" not found in ('NONE', 'QUESTION', 'ERROR',...)
Read more: https://b3d.interplanety.org/en/how-to-get-all-possible-enumproperty-values-for-function-parameters/
Комментарии
Отправить комментарий