I am trying to call a report() function when a drop down menu item is selected/changed.

Everything works well but the report() function returns:

Type Object 'Scene' has no attribute 'report'

I think I am very close to get this solved. Code as below:

class PanelSetting(NonSelectedPanel, bpy.types.Panel):
    bl_idname = "VIEW3D_PT_PanelSetting"
    bl_label = "Setting"

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

       #Set T Options
       box = row.box()
       row = box.row()
       # add an enum property menu
       # this allows only certain values to be set for a property
       box.prop_menu_enum(context.scene, 't_option', text=context.scene.t_option, icon='SNAP_PEEL_OBJECT')

t_menu_items = [
           #(identifier, name, description, icon, number)
               ('0.05 mm','0.05 mm','',1),
               ('0.1 mm','0.1 mm','',2),
               ('0.2 mm','0.2 mm','',3)

#Function to call when value is changed
def tChange(self, context):
    #The print function works fine
    print('T changed to ', context.scene.t_option)
    #THIS report function does not work as expected returns error:
    #"Type Object 'Scene' has no attribute 'report'"
    self.report({'INFO'}, "T changed to "+context.scene.t_option)

#set "bpy.types.Scene.t_option" to EnumProperty and call Function "tChange" when changed
def register():
    bpy.types.Scene.t_option = bpy.props.EnumProperty(items=t_menu_items, 
            default = '0.2 mm',  update = tChange)
  • $\begingroup$ Report can only be used in operators. See: blender.stackexchange.com/questions/1826/… $\endgroup$ – Ray Mairlot May 19 '18 at 19:21
  • $\begingroup$ is there a good way to work around so when selection is changed, it gets a report output or some way similar? $\endgroup$ – adrian li May 19 '18 at 19:28
  • $\begingroup$ could try calling an operator that reports in your update method. Pass the message to the operator as a string. $\endgroup$ – batFINGER May 20 '18 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.