Install shelf from folder drag and drop

Hello! I would like to know if there’s a way in python to install self buttons in maya from the installation folder to maya directly.

So could install my shelf from whatever folder i use on the disk.
I think advanced skeleton does that, we have a ‘intall.mel’ that we can drag and drop in maya then it intalls all the shelves needed.

Is anyone can help ?


Yes, I do this with python! Let me whip up an example…

import os
import logging
import maya.cmds as cmds

logger = logging.getLogger(__name__)

def onMayaDroppedPythonFile(obj):

    mod_directory = os.path.dirname(__file__)
    mod_file_path = os.path.join(mod_directory, "myMod.mod")

    with open(mod_file_path, "w") as file_object:

        file_object.write("+ MyMod 1.0 {0}".format(mod_directory))"Created mod file {0}".format(mod_file_path))

    # Generate Shelf

    window = cmds.window()
    shelf = cmds.shelfLayout()

    icon_directory = os.path.join(mod_directory, "icons")

    buttons = [

            "label": "Do Stuff",
            "annotation": "It does something...",
            "image1": os.path.join(icon_directory, "do_stuff.png"),
            "command": "from do_stuff import do\ndo()",

    for btn in buttons:

    cmds.saveShelf(shelf, os.path.join(mod_directory, "shelf_MyMod"))"Created shelf file {0}".format(
        os.path.join(mod_directory, "shelf_MyMod.mel")))

This basically generates a mod and shelf file in the folder i dragged the script from. The onMayaDroppedPythonFile is a hard coded Maya thing you need for the drag drop mechanic to work. I then put the mod/shelf files in the appropriate location. You could however have it save it in the right path, or edit the env file etc… lots of ways to do it. For me this was the cleanest way i found - generate the mod file but allow the user to place it in the right location.

1 Like

Hello! Thank you soo much for the exemple!! Great help. I was a bit confused about not seing the shelf first but i understood why! I can see the effect now!! This is exactly what i needed to know. Strange thing is that i struggle to find usefull info on this! Should pin this topic ^^!