Skip to content

Instantly share code, notes, and snippets.

View BigRoy's full-sized avatar

Roy Nieterau BigRoy

View GitHub Profile
@BigRoy
BigRoy / maya_usd_set_export_attributes_per_node.py
Last active June 3, 2025 14:37
Utility functions to easily set some attributes on Maya nodes for Maya USD Export to use.
"""Utility functions to easily set some attributes on Maya nodes for Maya USD Export to use.
For example, make it easy to set the purpose, type or kind for the resulting USD Prims.
See Maya USD - Custom Attributes and Tagging for USD:
https://github.com/Autodesk/maya-usd/blob/dev/lib/mayaUsd/commands/Readme.md#custom-attributes-and-tagging-for-usd
"""
from __future__ import annotations
from maya import cmds
@BigRoy
BigRoy / maya_hypershade_delete_all_disk_tabs.py
Last active May 21, 2025 20:52
Maya Delete all "disk" type tabs in Hypershade to avoid slow hypershade open
# See topic: https://forums.autodesk.com/t5/maya-programming-forum/hypershade-remove-tab-quot-projects-quot-on-startup/td-p/13642706
from maya import cmds
from maya import mel
# def reset_hypershade_panel_lookup_table():
# mel.eval("lookupTableReset($gHyperShadePanelLookupTable);")
def delete_tab_optionvar(optionvar: str):
@BigRoy
BigRoy / maya_set_mesh_usd_subdivision_scheme.py
Created May 20, 2025 10:23
Simple example script on how to set `USD_subdivisionScheme` attribute on Maya selected meshes with Python to override per-mesh Maya USD Export subdivision scheme
from typing import Literal
import maya.cmds as cmds
def set_usd_subdivision_scheme(
mesh: str,
scheme: Literal["catmullClark", "none", "loop", "bilinear", None] = "catmullClark"
):
"""Set mesh USD Subdivision Scheme for export
@BigRoy
BigRoy / run_with_oiiotool_2.3.10.txt
Last active April 23, 2025 10:57
Debug speed issue with oiiotool.exe with multichannel EXRs
==================
>> oiiotool --buildinfo
Invalid option "--buildinfo"
oiiotool -- simple image processing operations
OpenImageIO 2.3.10 http://www.openimageio.org
Usage: oiiotool [filename|command]...
Important usage tips:
* The oiiotool command line is processed in order, LEFT to RIGHT.
@BigRoy
BigRoy / resolve_update_timeline_version_name.py
Created April 17, 2025 13:55
Resolve script to match version in name of selected timeline items in media pool to current resolve project version number
"""Set selected Resolvetimeline name versions to project name version."""
from typing import Optional
import re
import DaVinciResolveScript as bmd
VERSION_REGEX = re.compile(r'_v(\d+)')
resolve = bmd.scriptapp('Resolve')
from typing import Tuple, Union, Optional
def get_tool_resolution(
tool,
output: Union[str, int, None] = None,
frame: Optional[int] = None,
allow_fast_dod_query=True
) -> Tuple[int, int]:
"""Return tool output resolution.
@BigRoy
BigRoy / ayon_check_loaded_version_input_versions_in_scene.py
Last active March 14, 2025 17:20
In AYON pipeline print a message if e.g. loaded look product was generated using a different model version than you have in your current scene.
"""
Example on using AYON's generative links to query whether the loaded products
in current workfile happen to have input products that some of the products
were also generated with and see if those versions match.
For example: You have a loaded model v002 and loaded look v001, however
that look version was created using model v001. You may want to identify that.
This script will print out a message for each product that has a version in the
inputs where another version of that input product is loaded in the scene.
@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,