forked from bartvdbraak/blender
163f6055d2
poll() function is now a static method in python, this is more correct, matching C where the operator is not created to run poll. def poll(self, context): ... is now... @staticmethod def poll(context): ... Pythons way of doing static methods is a bit odd but cant be helped :| This does make subclassing poll functions with COMPAT_ENGINES break, so had to modify quite a few scripts for this.
23 lines
457 B
Python
23 lines
457 B
Python
import bpy
|
|
|
|
def main(context):
|
|
for ob in context.scene.objects:
|
|
print(ob)
|
|
|
|
class SimpleOperator(bpy.types.Operator):
|
|
''''''
|
|
bl_idname = "object.simple_operator"
|
|
bl_label = "Simple Object Operator"
|
|
|
|
@staticmethod
|
|
def poll(context):
|
|
return context.active_object != None
|
|
|
|
def execute(self, context):
|
|
main(context)
|
|
return {'FINISHED'}
|
|
|
|
|
|
if __name__ == "__main__":
|
|
bpy.ops.object.simple_operator()
|