Last active
March 20, 2022 04:27
-
-
Save jeangjenq/94d4f6d1d3be7e4910451ef6b3764829 to your computer and use it in GitHub Desktop.
Improved OpenFolder from Pr_Suite for Nuke.
This file contains hidden or 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
def open_folder(path): | |
""" | |
Open folder based on OS. | |
:param path: Directory path | |
:type path: str | |
:return: None | |
:rtype: None | |
""" | |
if platform.system() == "Windows": | |
os.startfile(os.path.abspath(path)) | |
elif platform.system() == "Darwin": | |
subprocess.Popen(["open", path]) | |
elif platform.system() == "Linux": | |
subprocess.check_call(["xdg-open", path]) | |
else: | |
nuke.message("Unsupported OS") | |
def open_read_file(): | |
""" | |
Open folder for selected node with file knob. | |
:return: None | |
:rtype: None | |
""" | |
read_path = [] | |
for node in nuke.selectedNodes(): | |
for knob in node.knobs(): | |
current_knob = node[knob] | |
if current_knob.Class() == 'File_Knob': | |
if current_knob.evaluate() is not None: | |
if os.path.dirname(current_knob.evaluate()) not in read_path: | |
read_path.append(os.path.dirname(current_knob.evaluate())) | |
if len(read_path) > 4: | |
if nuke.ask('About to open ' + str(len(read_path)) + " paths, continue?"): | |
for path in read_path: | |
open_folder(path) | |
else: | |
for path in read_path: | |
open_folder(path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment