Skip to content

Commit

Permalink
Handle execution based on file type to allow launching files via Appl…
Browse files Browse the repository at this point in the history
…ication Launcher items
  • Loading branch information
wgergely committed Oct 31, 2023
1 parent 93a20ba commit 2b6ea48
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 2 deletions.
65 changes: 65 additions & 0 deletions bookmarks/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1434,6 +1434,68 @@ def execute(index, first=False):
else:
path = common.get_sequence_end_path(path)

ext = QtCore.QFileInfo(path).suffix()

# Handle Maya files
if ext in ('ma', 'mb'):
for app in (
'maya', 'maya2017', 'maya2018', 'maya2019', 'maya2020', 'maya2022', 'maya2023', 'maya2024',
'maya2025', 'maya2026'
):
executable = common.get_binary(app)
if not executable:
continue
execute_detached(executable, args=['-file', path])
return

# Handle Nuke files
if ext in ('nk', 'nknc'):
executable = common.get_binary('nuke')
if executable:
execute_detached(path, args=[path,])
return

# Handle Houdini files
if ext == 'hiplc':
for app in ('houdiniinidie', 'houindie', 'houind', 'houdiniind', 'hindie'):
executable = common.get_binary(app)
if executable:
execute_detached(executable, args=[path,])
return

if ext == 'hip':
for app in ('houdini', 'houdinifx', 'houfx', 'hfx', 'houdinicore', 'hcore'):
executable = common.get_binary(app)
if executable:
execute_detached(executable, args=[path,])
return

# Handle RV files
if ext == 'rv':
for app in ('rv', 'tweakrv', 'shotgunrv', 'shotgridrv', 'sgrv'):
executable = common.get_binary(app)
if executable:
execute_detached(executable, args=[path,])
return

# Handle blender files
if ext in ('blend', ):
for app in ('blender', 'blender2.8', 'blender2.9', 'blender3', 'blender3.0', 'blender3.1', 'blender3.2',
'blender3.3', 'blender3.4', 'blender3.5'
):
executable = common.get_binary(app)
if executable:
execute_detached(executable, args=[path,])
return

# Handle After Effects files
if ext in ('aep', ):
for app in ('afterfx', 'aftereffects', 'ae', 'afx'):
executable = common.get_binary(app)
if executable:
execute_detached(executable, args=[path,])
return

url = QtCore.QUrl.fromLocalFile(path)
QtGui.QDesktopServices.openUrl(url)

Expand Down Expand Up @@ -1544,6 +1606,9 @@ def execute_detached(path, args=None):
On Windows, we'll call the given file using the file explorer as we want to
avoid the process inheriting the parent process' environment variables.
Args:
path (str): The path to the file to execute.
args (list): A list of optional arguments to pass to the process.
"""
if common.get_platform() == common.PlatformWindows:
proc = QtCore.QProcess()
Expand Down
4 changes: 2 additions & 2 deletions bookmarks/maya/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def save_scene(increment=False, type='mayaAscii'):
@common.error
@common.debug
def execute(index):
"""Action used to execute a selected file item.
"""Action used to execute a selected file item in Maya.
"""
file_path = common.get_sequence_end_path(
Expand All @@ -226,7 +226,7 @@ def execute(index):
file_info = QtCore.QFileInfo(file_path)

# Open alembic, and maya files:
if file_info.suffix().lower() in ('ma', 'mb', 'abc'):
if file_info.suffix().lower() in ('ma', 'mb', 'abc', 'obj', 'fbx', 'usd', 'usda', 'usdc'):
open_scene(file_info.filePath())
return

Expand Down

0 comments on commit 2b6ea48

Please sign in to comment.