Skip to content

Instantly share code, notes, and snippets.

View BigRoy's full-sized avatar

Roy Nieterau BigRoy

View GitHub Profile
@BigRoy
BigRoy / ayon_loader_plugin_host_specific.py
Created February 6, 2025 12:20
Make AYON loader plug-in host specific using `LoaderPlugin.is_compatible_loader` classmethod
from ayon_core.pipeline import load, get_current_host_name
class TestHostSpecificLoad(load.LoaderPlugin):
hosts = ["bla"]
product_types = {"*"}
representations = {"*"}
label = "Test Host Specific Load"
@BigRoy
BigRoy / maya_list_plugin_paths.py
Last active February 6, 2025 13:50
Maya list all available plug-ins (including unloaded ones) using Python
from typing import Tuple, List
from pathlib import Path
import os
import platform
# Get plugin extensions maya can load per platform
PLUGIN_EXTENSIONS_BY_PLATFORM = {
"windows": {".mll", ".nll.dll"},
"mac": {".bundle"},
"linux": {".so"},
@BigRoy
BigRoy / fusion_swap_tools.py
Last active January 31, 2025 21:27
Fusion script to swap two selected tools, which swaps their position and connections
from typing import List, Iterable
import itertools
import contextlib
@contextlib.contextmanager
def comp_lock_and_undo_chunk(
comp,
undo_queue_name="Script CMD",
keep_undo=True,
@BigRoy
BigRoy / ayon_fusion_imprint_unmanaged_loaders.py
Created January 20, 2025 20:23
AYON Fusion integration imprint container to all loaders loading a published filepath that is currently not linked
"""Fix unlinked/unmanaged loaders in Fusion to get managed by AYON as intended."""
from pathlib import Path
from typing import List
import time
import logging
import ayon_api
from ayon_core.pipeline import get_current_project_name
@BigRoy
BigRoy / maya_create_rs_mesh_parameters_per_node.py
Last active January 15, 2025 11:13
Maya Create rsMeshParameters per node in selection and add node name as suffix label
# Maya Create rsMeshParameters per node in selection and add node name as suffix label
import contextlib
from maya import cmds, mel
@contextlib.contextmanager
def maintained_selection():
previous_selection = cmds.ls(selection=True)
try:
yield
@BigRoy
BigRoy / observe_pyblish_data_changes.py
Last active December 20, 2024 17:18
Capture instance.data and context.data reads and writes from Pyblish plugins (the instances must already exist at the specified CollectorOrder!)
"""This plug-in will do some heavy logging of all reads and changes to any
instance.data or context.data by pyblish plug-ins and will generate a JSON
This requires typing-extensions and observatory library and will in the worst
possible manner add those to sys.path to make it work. This is a quick hack.
Dependencies:
observatory: https://github.com/sharpencrag/observatory
typing_extensions: https://github.com/python/typing_extensions
@BigRoy
BigRoy / ayon_maya_use_cbid_for_connection_post_process.py
Last active December 20, 2024 09:53
Example script using AYON Maya integration 'cbId' to perform a post-process 'connection' between source and target cbId in the current scene
# Perform a 'connection' between dag nodes in Maya based on their cbId
from typing import Dict
from maya import cmds
from ayon_maya.api import lib
mapping: Dict[str, str] = {
# Data mapping is like:
"source-id": "target-id",
# Example:
"ac991b60b4cb11eeb7fc7730318c5a70:c0ce772a9052": "ac991b60b4cb11eeb7fc7730318c5a70:f328201a4e8b"
@BigRoy
BigRoy / maya_script_editor_word_wrap.py
Created November 14, 2024 11:21
Force enable Word Wrap in Maya's script editor output
import maya.OpenMayaUI as mui
import shiboken2
from PySide2 import QtWidgets
# <-- get maya main window QMainWindow -->
ptr = mui.MQtUtil.mainWindow()
main_window = shiboken2.wrapInstance(int(ptr), QtWidgets.QMainWindow)
# <-- set wordWrap on script editor feedback field -->
cmdScrollFieldReporter = main_window.findChild(QtWidgets.QPlainTextEdit, "cmdScrollFieldReporter1")
@BigRoy
BigRoy / maya_export_chaser_filter_properties.py
Last active November 13, 2024 23:22
Maya USD Export Chaser to filter properties using SideFX-Houdini like parameter pattern matching
import re
import logging
from typing import List
import mayaUsd.lib as mayaUsdLib
from pxr import Sdf
def log_errors(fn):
"""Decorator to log errors on error"""
@BigRoy
BigRoy / ayon_print_settings_change_event_diffs.py
Last active November 6, 2024 00:15
AYON debug print settings changes
import json
import difflib
import ayon_api
amount = 10
for event_ in ayon_api.get_events(
topics={"settings.changed"},
# Set more filters if needed
# newer_than="isoformat-date",