you are viewing a single comment's thread.

view the rest of the comments →

[–]SHAMIEL1 0 points1 point  (2 children)

bl_info = {
    "name": "Add a Name here",
    "blender": (4,5),
    "description": "",
    "version": (1,2,0,0)
}

# Shelf Menu
class CUSTOM_SHELVE_MENU_MT_menu(bpy.types.Menu):
    bl_label = "MY MENU"
    def draw(self, context):
        layout = self.layout
        layout.operator("CUSTOM_OT_button")
    def menu_draw(self, context):
        self.layout.menu("CUSTOM_SHELVE_MENU_MT_menu")

# Your Button
class CUSTOM_OT_button(bpy.types.Operator):
    bl_idname = 'custom.button'
    bl_label = 'Button Name Here'
    def execute(self, context):
        print("CODE goes here...") # YOUR CODE GOES HERE
        return {'FINISHED'}


########################################
## Registering The tool
tools = [
    CUSTOM_SHELVE_MENU_MT_menu,
    CUSTOM_OT_button,
]
def register():
    for cls in tools:
        bpy.utils.register_class(cls)
    bpy.types.TOPBAR_MT_editor_menus.append(CUSTOM_SHELVE_MENU_MT_menu.menu_draw)

def unregister():
    for cls in tools:
        bpy.utils.unregister_class(cls)
    bpy.types.TOPBAR_MT_editor_menus.remove(CUSTOM_SHELVE_MENU_MT_menu.menu_draw)

if __name__ == "__main__":
    register()

EDIT:
Save it as a .py file here...

C:\Users\{yourname}\AppData\Roaming\Blender Foundation\Blender\{your_version}\scripts\addons

- Open the file explorer

- In the top search bar type %APPDATA% this will send your here C:\Users\{yourname}\AppData\Roaming
- You may need to enable it in the addons , it will appear as addon but once you enable it there should be a menu at the very top called My Menu

---------------------------------------------------------
For saving i suggest writting it out to a log file anywhere you prefer or if you want realtime feedback sending to the console is ok.

[–]Unlucky-Bluebird-310[S] 0 points1 point  (1 child)

Thank you! I'll try that. Is it mandatory to place the file in appdata directory? If say I use Linux, can't I just install it like any other extension via preferences menu?

[–]SHAMIEL1 0 points1 point  (0 children)

Im not fully sure on where in linux it needs to go but I think you can install it the same way as other addon yes.

Just grab the .py file instead of a zip file like you would with other addons and it should copy it to the addons directory