2
$\begingroup$

I have an operator with a class name of say Mesh_OT_Add_Thing. Printing self.__class__ shows that the class is __main__.Mesh_OT_Add_Thing. I've tried a few different ways but can't seem to get to the class to check a specific member.

How do I do this?

$\endgroup$
  • $\begingroup$ Where do you want to access your Operator class? I can successfully access another Operator class from the same directory using from . import my_operator. And I think it is also possible using class path. $\endgroup$ – TheBusyTypist Jan 20 '15 at 4:45
  • $\begingroup$ From the python command line in blender. Ill try the import thing when i get time tomorrow and use the from [path] part you suggested and let you know the results $\endgroup$ – Coburn Jan 20 '15 at 4:57
2
$\begingroup$

You can access classes for registered operators via bpy.types.

eg:

cls = bpy.types.OBJECT_OT_make_dupli_face

import inspect

inspect.getsourcefile(cls)
# 'release/scripts/startup/bl_operators/object.py'

inspect.getsource(cls)
# 'class MakeDupliFace(Operator):\n    """Convert objects ... <snip>
$\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.