-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstall.py
58 lines (44 loc) · 1.28 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
"""
Drag and drop for Maya 2018+
"""
import os
import sys
try:
import maya.mel
import maya.cmds
isMaya = True
except ImportError:
isMaya = False
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."""
source_path = os.path.join(os.path.dirname(__file__))
source_path = os.path.normpath(source_path)
command = """
# -----------------------------------
# intersections-tool
# -----------------------------------
import os
import sys
if not os.path.exists(r'{path}'):
raise IOError(r'The source path "{path}" does not exist!')
if r'{path}' not in sys.path:
sys.path.insert(0, r'{path}')
import intersections_tool
intersections_tool.show()
""".format(path=source_path)
shelf = maya.mel.eval('$gShelfTopLevel=$gShelfTopLevel')
parent = maya.cmds.tabLayout(shelf, query=True, selectTab=True)
maya.cmds.shelfButton(
command=command,
annotation="Intersections Tool",
sourceType="Python",
parent=parent,
image="pythonFamily.png",
image1="pythonFamily.png",
imageOverlayLabel="Intersections Tool"
)
if isMaya:
_onMayaDropped()