Created
September 11, 2020 06:07
-
-
Save dbr/cc15fb447d1f6328551b5d6bff478386 to your computer and use it in GitHub Desktop.
Method to find external nodes
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 _find_ext_nodes(extension, ignore_classes=None): | |
# type: (str, Optional[List[str]]) -> Dict[str, nuke.Node] | |
"""Find nodes which are not part of default Nuke | |
""" | |
if ignore_classes is None: | |
ignore_classes = [] | |
by_class = {} # type: Dict[str, nuke.Node] | |
for n in nuke.allNodes(recurseGroups=True): | |
by_class.setdefault(n.Class(), []).append(n) | |
# Ignore nodes bundled with Nuke | |
nuke_dir = os.path.dirname(nuke.env['ExecutablePath']) | |
gizmo_usage = {} | |
for cls, nodes in by_class.items(): | |
if cls in ignore_classes: continue | |
plugins = nuke.plugins(0, "%s.%s" % (cls, extension)) | |
for plug in plugins: | |
if plug.startswith(nuke_dir): | |
continue | |
gizmo_usage[cls] = nodes | |
return gizmo_usage | |
def find_gizmos(): | |
# type: () -> Dict[str, nuke.Node] | |
"""Find nodes which could be turned into group | |
""" | |
return _find_ext_nodes("gizmo") | |
def find_plugins(ignore_classes=None): | |
# type: (Optional[List[str]]) -> Dict[str, nuke.Node] | |
"""Find nodes which cannot be degizmoed, but are not part of Nuke | |
""" | |
plugins = _find_ext_nodes(nuke.env['PluginExtension'], ignore_classes=ignore_classes) | |
if ignore_classes is None: | |
ignore_classes = [] | |
# Also find OFX based plugin | |
for n in nuke.allNodes(recurseGroups=True): | |
if n.Class().startswith("OFX"): | |
# Ignore builtin OFX nodes | |
if n.Class().startswith("OFXuk.co.thefoundry."): continue # FIXME: Technically wrong, e.g Furnace? | |
# Ignore allowed nodes | |
if n.Class() in ignore_classes: continue | |
plugins.setdefault(n.Class(), []).append(n) | |
return plugins |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment