-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.py
88 lines (66 loc) · 1.88 KB
/
install.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Documentation:
"""
# @Time : 20-Apr-22
# @File : install.py
# @User: MICHAEL
__version__ = "1.0.1"
__author__ = "Michael Reda"
__email__ = "eng.michaelreda@gmail.com"
__license__ = "GPL"
__copyright__ = "Michael Reda"
__status__ = "Beta"
# ---------------------------------
# import libraries
import sys
import os
# ---------------------------------
# Variables
__python__ = sys.version_info[0]
try:
import maya.mel
import maya.cmds
isMaya = True
except ImportError:
isMaya = False
# ---------------------------------
# start here
# ---------------------------------
def onMayaDroppedPythonFile(*args, **kwargs):
"""This function is only supported since Maya 2017 Update 3"""
pass
def _onMayaDropped():
"""Dragging and dropping this file into the scene executes the file."""
src_path = os.path.join(os.path.dirname(__file__), 'src')
icon_path = os.path.join(src_path, 'icons', 'logo.png')
src_path = os.path.normpath(src_path)
icon_path = os.path.normpath(icon_path)
if not os.path.exists(icon_path):
raise IOError('Cannot find ' + icon_path)
command = '''
# ---------------------------------
# To automate the download and bind texture with fbx file
# www.cgtrader.com
# -----------------------------------
import sys
root_path = r'{path}'
if not root_path in sys.path:
sys.path.append(root_path)
sys.argv = [r'{path}\main.py']
with open(r'{path}\main.py', 'r') as f:
exec(f.read())
'''.format(path=src_path)
shelf = maya.mel.eval('$gShelfTopLevel=$gShelfTopLevel')
parent = maya.cmds.tabLayout(shelf, query=True, selectTab=True)
maya.cmds.shelfButton(
command=command,
annotation='FBX Automation Tool',
sourceType='Python',
image=icon_path,
image1=icon_path,
parent=parent
)
if isMaya:
_onMayaDropped()