Render Warning addon

Hi. I’m a bit new to Python with Blender.

I started working on a script that warns you when you try to render an animation and you output directory is set to tmp. I’m planning to extend it to have a list of directory’s to warn you about (the place you store all your .blend files, tmp, etc). I’m also wanting to add support for warnings about folders that have numbered images and pop up windows instead of the print() statement that it currently has.

Heres my current code. Feel free to try it out and tell me how it works.

If you try it you’ll need to switch


if tmp == "/tmp/":

to a different folder depending on your system.


bl_info = {
    "name": "Render Warning",
    "category": "Object",
}

import bpy


class RenderWarning(bpy.types.Operator):
    """Object Cursor Array"""
    bl_idname = "render.render_warning"
    bl_label = "Render Warning"
    bl_options = {'REGISTER', 'UNDO'}

    def execute(self, context):
        tmp = context.scene.render.filepath
        
        if tmp == "/tmp/":
            self.report({'WARNING'}, "You are in the /tmp/ directory")
        else:
            #bpy.ops.render.render(animation = True)
            self.report({'WARNING'}, "rendering")

        return {'FINISHED'}
    
def menu_func(self, context):
    self.layout.operator(RenderWarning.bl_idname)


def register():
    bpy.utils.register_class(RenderWarning)
    bpy.types.VIEW3D_MT_object.append(menu_func)

def unregister():
    bpy.utils.unregister_class(RenderWarning)
    bpy.types.VIEW3D_MT_object.remove(menu_func)



if __name__ == "__main__":
    register()



EDIT:
Updated the code

If you could give me some suggestions, it would be appreciated.

bpy.data.scenes[“Scene”]
should be
context.scene

    if tmp == "/tmp/":

is not safe across different platforms, on windows it is
‘/tmp\’

print(“You are in the /tmp/ directory”)
You should probably use self.report()

Ok. I’ll change it.

I am aware that /tmp/ is not the same across platforms. Thats why I said that you need to switch that folder depending on your system.

If your thinking that all of the code is how it will be when it’s done you are incorrect. I’m just taking it little steps at a time.

Is self.report() the method for using that little space at the top of the screen for warnings and stuff?

Thank you for your feedback. I highly appreciate it.

Ok. I got self.report() to work. The context.scene thing isn’t giving me any errors and the script is still working fine.

Thank you for self.report(). That was one of the things I was wanting to do.