Beispiel #1
0
def getSubstrates():
    """
    Downloads and extracts the substrate textures
    """
    url = "https://researchdata.ntu.edu.sg/api/access/datafile/2793?gbrecs=true"
    if lib.localOS() == "mac":
        result = cmds.confirmDialog(t="Download substrates", m="Please download the substrates and extract them into the textures folder of MNPR.", b="Download", icn="information")
        if result == "Download":
            lib.openUrl("https://doi.org/10.21979/N9/HI7GT7")
            lib.openUrl(url)
            return
        else:
            print "No substrates will be downloaded.",
            return
    # windows and linux
    import zipfile
    result = cmds.confirmDialog(t="Downloading substrates", m="Do you wish to download the substrates \nautomatically in the background?", b=['Yes', 'Manual download', 'Close'], icn="question")
    if result == "Manual download":
        lib.openUrl("https://doi.org/10.21979/N9/HI7GT7")
        lib.openUrl(url)
        return
    elif result == "Close":
        print "No substrates will be downloaded.",
        return
    else:
        p = lib.Path(lib.getLibDir())
        p.parent().child("textures")
        dest = os.path.join(p.path, "seamless_textures_light.zip")
        if lib.downloader(url, dest):
            print "Substrates downloaded, extracting..."
            zip = zipfile.ZipFile(dest, 'r')
            zip.extractall(p.path)
            zip.close()
            os.remove(dest)
            print "MNPR substrates installed successfully",
            cmds.confirmDialog(t="Download successful", m="The substrates downloaded successfully", b="Yay!", icn="information")
        else:
            cmds.warning("Problem downloading substrates, please download and install manually")
            result = cmds.confirmDialog(t="Download substrates", m="Please download the substrates and extract them into the textures folder of MNPR.", b="Download", icn="information")
            if result == "Download":
                lib.openUrl("https://doi.org/10.21979/N9/HI7GT7")
                lib.openUrl(url)
Beispiel #2
0
def getPlugin(variables):
    """
    Gets the plugin locally or online
    Args:
        variables (dict): environment variables
    """
    pluginName = "MNPR{0}".format(ext)

    # check if plugin is available, otherwise, download
    pluginDir = variables["MAYA_PLUG_IN_PATH"][0]
    lib.createDirectory(pluginDir)
    filesInDir = os.listdir(pluginDir)
    if not filesInDir:
        # download the right plugin for the OS and Maya version
        pluginURL = "{0}/plugins".format(distURL)
        pluginURL += "/{0}".format(mayaV)  # add Maya version
        pluginURL += "/{0}".format(lib.localOS())  # add OS
        pluginURL += "/{0}".format(pluginName)  # add plugin name

        # get plugin file online
        print("Getting plugin from: {0}".format(pluginURL))
        lib.printInfo("Downloading plugin...")
        downloader = urllib.URLopener()
        downloader.retrieve(pluginURL, os.path.join(pluginDir, pluginName))
Beispiel #3
0
@run:           Drag and drop the install.mel file which runs coopSetup
@contributors:  Santiago Montesdeoca
"""
from __future__ import print_function
import os, shutil, urllib, pprint
import maya.cmds as cmds
import maya.mel as mel
import coopLib as lib

# GET MAYA VERSION
mayaV = int(lib.mayaVersion())
if mayaV < 2017:
    cmds.error("Plugin is only supported by Maya 2017, onwards.")

# SETTLE OS DEPENDENT CASES
localOS = lib.localOS()
sep = ':'  # separator
if localOS == "win":
    sep = ';'


def run(root):
    """
    Insert system paths in the Maya.env
    Args:
        root: root directory of the plugin hierarchy
    """
    print("-> Installing plugin")
    variables = {'MAYA_MODULE_PATH': [os.path.abspath(root)]}

    # get Maya.env file