error on report command ?

i have these lines
which where working last year but now seems theya re not anymore

how can this corrected ?



    import traceback
    <b>self.report({'ERROR'}, </b>"Error evaluating expression: "
     + traceback.format_exc(limit=1))


error on report name ?

thanks

anyone can help with this mystery !

thanks

Hi Ricky.

I put together these test scripts from the templates. Any of the ERROR type reports will throw an error from the test call when the operator script is run from the script window, yet work as desired from the button in the panel, or when called from search box…


import bpy
from bpy.props import StringProperty




class SimpleOperator(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"
    report_type = StringProperty(default='INFO')
    @classmethod
    def poll(cls, context):
        return context.active_object is not None


    def execute(self, context):
        #import traceback
        self.report({self.report_type}, "Blippo blippo")
        return {'FINISHED'}




def register():
    bpy.utils.register_class(SimpleOperator)




def unregister():
    bpy.utils.unregister_class(SimpleOperator)




if __name__ == "__main__":
    register()


    # test call
    bpy.ops.object.simple_operator()


import bpy




class HelloWorldPanel(bpy.types.Panel):
    """Creates a Panel in the Object properties window"""
    bl_label = "Test Reports"
    bl_idname = "OBJECT_PT_hello"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "object"


    def draw(self, context):
        layout = self.layout




        for rep_type in ['DEBUG', 'INFO', 'OPERATOR', 'WARNING', 'ERROR', 'ERROR_INVALID_INPUT', 'ERROR_INVALID_CONTEXT', 'ERROR_OUT_OF_MEMORY']:
            row = layout.row()
            row.operator("object.simple_operator", text=rep_type).report_type = rep_type




def register():
    bpy.utils.register_class(HelloWorldPanel)




def unregister():
    bpy.utils.unregister_class(HelloWorldPanel)




if __name__ == "__main__":
    register()

thanks for example
i’ll have to re try it and see why there is an error on these ones!

be back may be later on

merry christmass and a happy new year !

happy cycles

this might be a little more complicated
right now i get an error on line 1
and there is nothing on line 1

i have other functions which are working with this but these ones gives an error on a float number and this report thing

so i guess better that you have a look onto the whole file to better see what might be wrong with this value!

so here is the file

zseahell3.blend (813 KB)

just run the script and then Add mesh then select at bottom of list the seashell item and then select the first item in list

then it will crash on this report error as the last error !

hope this can work so i can release these nice shapes!

thanks

Ricky

the issue isn’t with the report.

h is defined as a global


h = 0.4

To use self.report here you expect self to be an operator.

 
def xyz_function_surface_faces(self, x_eq, y_eq, z_eq,
    range_u_min, range_u_max, range_u_step, wrap_u,
    range_v_min, range_v_max, range_v_step, wrap_v,
    a_eq, b_eq, c_eq,d_eq,e_eq, f_eq, g_eq, h_eq,i_eq,j_eq,k_eq,l1a_eq,m_eq,alpha_eq ,beta_eq,mu_eq,omega_eq,phi_eq,n, close_v):


and here


def add_xyz_object(helper=h, param=samples[0], resolution=32):

...

    (verts, faces) =xyz_function_surface_faces(
        h, p["x"], p["y"], p["z"], p["umin"], p["umax"], resolution, False, p["vmin"], p["vmax"], resolution, False,  
        afunc, bfunc, cfunc,dfunc, efunc, ffunc, gfunc, hfunc,ifunc,jfunc,kfunc,l1afunc,mfunc,alphafunc,betafunc,mufunc,omegafunc,phifunc, 1, False)
...

When you call this from the operator once again you pass h



o1 = add_xyz_object(helper=h,param=samples[ia1],resolution=seg1)

This is why you get the float object has no attribute report.

The line 1 error occurs in one of your code object modules…


j = float(eval(*expr_args_j))

sorry for the delay!

if you execute the last function loxodrome shell
these equations works fine!

so still not certain why this h error is coming up

1
“When you call this from the operator once again you pass h”

not following here

are you saying i’m repeating this h value in a call ?

2 how did you find that it was this value in error?

j = float(eval(*expr_args_j))

i did check again this equation and seems to work fine

now if it is this var it means that it cannot calculate a real value may be!

any special way to see this error and lines number?

if i add at beginning the extended error reporting is it going to show this error or not?

i tried to follow the method of another script but i had to modify and add a lot of new variables in the function
i may have made an error !

most of the others functions are working fine except this big one with a lot of complicated calculations!

thanks

you may test the type for debugging:

if not isinstance(self, bpy.types.Operator):
    print("self has bad type for .report")
elif not hasattr(self, "report"):
    print("operator has no report()")

do you mean to replace these lines

self.report({‘ERROR’}, "Error evaluating expression: "

  • traceback.format_exc(limit=1))

with the new lines?

would like to get the first one working after that i can make most of the other works well hopefully

tried it and get this

resol = 32
%%% self has bad type for .report

so how can this be corrected ?
is there some type i can add and how ?

thanks

self isn’t a keyword in python, you could call it however you want. Whatever is the first parameter of a class function (method) will be used as self-reference (to the own class instance, like $this in PHP). For self.report, self needs to be that first parameter of a method, and the class has to be derived from bpy.types.Operator, and the method must not be @classmethod nor @staticmethod. self.report() won’t be available outside of such a method (unless an external function is called the self gets passed to it).

problem is that it does not tell me which var or lines is the problem
it becomes hard to guess what is wrong if there is not indication or where it is!

i did debug another one yesterday night
i had made an error on one of the equations lines var

i’ll review this function and see if i miss an equation!

i got like 5 others wokign like a charm
but this one has a lot more equations and is more complicated
but same principal so it should also work nicely!

thanks