-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9fb6287
commit 5482274
Showing
4 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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() |