XBMLANGPATH path varible - implicit paths over explicit

I’m using the XBMLANGPATH variable in the Maya.env file which as far as I know stores the directories for icons etc? ( someone can clarify this for me? ) at the least I use this to customize my Maya splash screen…

anyhow I’d like to reference custom icons the same way… via this code


iconPath = os.environ
icon = iconPath['XBMLANGPATH'].rsplit(";")[0] + "/button.png"

problem with this is I’m explicitly calling the [0] entry which is the last added path variable via Maya.env…

how would I go about not explicitly determining this path…

chur!

Jamie

[0] is the first, [-1] is the last

So I’m not 100% sure I get what you’re asking, but if you’re looking to find the first button.png file that exists in the possible XBMLANGPATH locations, the following code should work.

Currently the function would return None if no path is found, so you’d need to guard against that, but hopefully this points you in the right direction.


def get_icon_path(name='button.png'):
    import os
    for icon in os.environ.get('XBMLANGPATH').split(os.pathsep):
        icon_path = os.path.join(icon, name)
        if os.path.exists(icon_path):
            return icon_path


Thanks Mr White…

yeah I wanted to be able to look for said icon where it be contained within list of directories stored in the XBMLANGPATH variable and not just in the one specified, so thanks for that little snippet.

I’m not sure if I’m going about this the right way anyhow… but with putting paths into the Maya.env file they are made available as soon as Maya starts. I do inject a custom scripts directory via the userSetup.py file and I presume I could setup a custom icons directory at that stage too.

the XBMLANGPATH is interesting thou as I can inject my own modified icons/images into maya by just have the same named file…

cheers!

I would avoid modifying MAYA.ENV and suggest appending your folder to the XBMLANGPATH during a startup script.
when we start up maya, we create a CUSTOM_ICONS environment variable. that makes it easy to retrieve that folder later instead of inspecting XBMLANGPATH.