Skip to content

Instantly share code, notes, and snippets.

@tin2tin
Created September 29, 2024 20:31
Show Gist options
  • Save tin2tin/17e2055d1ec70095cd655a110a31675d to your computer and use it in GitHub Desktop.
Save tin2tin/17e2055d1ec70095cd655a110a31675d to your computer and use it in GitHub Desktop.
Does operator exist?
import bpy
def operator_exists(idname):
# Split the idname string into the operator type and the operator function
idname_parts = idname.split(".")
if len(idname_parts) != 2:
return False # The idname is not properly formatted
operator_type, operator_func = idname_parts
# Check if the operator type and function exist in bpy.ops
return hasattr(getattr(bpy.ops, operator_type, None), operator_func)
# Example usage:
print(operator_exists("sequencer.generate_image")) # Returns True if the operator exists
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment