import math not working in a class?

Hi forum,

I have slightly adapted the template

import bpy
import math

class SimpleOperator(bpy.types.Operator):
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"

    def poll(cls, context):
        return context.active_object != None

    def execute(self, context):
        return {'FINISHED'}

if I run that, and press space in the viewport and type in simple object operator and select it, the console prints out the follow error

AttributeError: 'NoneType' object has no attribute 'pi'

changing the print statement to


results in None

How do I use the math (and mathutils) library inside the class?

SVN 32005 has no problem using math inside the operator, and prints nicely 3.1… :wink:

So you have an too old version of Blender 2.54!

Thank you, compiling the latest SVN solved the problem