operator_simple.py 636 B

123456789101112131415161718192021222324252627282930313233343536
  1. import bpy
  2. def main(context):
  3. for ob in context.scene.objects:
  4. print(ob)
  5. class SimpleOperator(bpy.types.Operator):
  6. """Tooltip"""
  7. bl_idname = "object.simple_operator"
  8. bl_label = "Simple Object Operator"
  9. @classmethod
  10. def poll(cls, context):
  11. return context.active_object is not None
  12. def execute(self, context):
  13. main(context)
  14. return {'FINISHED'}
  15. def register():
  16. bpy.utils.register_class(SimpleOperator)
  17. def unregister():
  18. bpy.utils.unregister_class(SimpleOperator)
  19. if __name__ == "__main__":
  20. register()
  21. # test call
  22. bpy.ops.object.simple_operator()