2

I've created a python script that creates a specific folder structure for my projects, and also saves the first instance of my project. I want this script to be run by clicking on a custom button in the render panel. Since this is to be done at the start of new projects I want this button to be part of the default startup in Blender. However, I can't find the information to do these things.

Here is my code, saved in a file called "EinarOptions.py":

import bpy

class EinarOptions(bpy.types.Panel):
    """Creates a Panel in the render context of the properties editor"""
    bl_label = "Einar options"
    bl_idname = "RENDER_PT_layout"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "render"

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

        # Different sizes in a row
        layout.label(text="Different button sizes:")
        row = layout.row()
        row.operator("render.render")

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

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

if __name__ == "__main__":
    register()

This creates a panel in Blender:

enter image description here

After having read through a lot of tutorials and getting lost in the documentation, I still got no clue. How do I create a button(similar to the one I have now, which says 'Render') that executes my script when pressed?

The script to be run is called "CreateFolderStructure.py" and is stored on my harddrive.

Humilton
  • 2,127
  • 1
  • 16
  • 36

0 Answers0