Skip to content

Instantly share code, notes, and snippets.

View BigRoy's full-sized avatar

Roy Nieterau BigRoy

View GitHub Profile
@BigRoy
BigRoy / ayon_maya_export_mode.py
Created December 3, 2025 23:13
Poor man's reopen scene plug-in set up with an "Export Mode" in AYON-Maya
import pyblish.api
from maya import cmds
ATTR = "__export_mode" # make sure to pick some quite unique name
class EnableExportModeAttributes(pyblish.api.ContextPlugin):
label = "Enable export modes"
order = pyblish.api.ExtractorOrder - 0.48 # after save scene
families = ["*"]
@BigRoy
BigRoy / maya_create_out_mesh_connected_duplicates.py
Created November 27, 2025 14:28
Create duplicates of selected nodes, and for
# Create a copy of selection, parent it to root and connect the `worldMesh` of the source to the `inMesh` of the target.
from maya import cmds
selection = cmds.ls(selection=True, long=True)
duplicates = []
for node in selection:
# Create a duplicate
dup = cmds.duplicate(node, renameChildren=True)[0]
# Parent it to root just so it's easily available
@BigRoy
BigRoy / maya_usd_export_set_user_exported_attributes_json.py
Created November 10, 2025 23:32
Python example on how to manipulate USD_UserExportedAttributesJson attribute on nodes to define how Maya USD exports custom attributes to the USD attribute names
from typing import Any
from maya import cmds
import json
ATTR: str = "USD_UserExportedAttributesJson"
def add_explicit_attribute_export_name(
node: str,
maya_attribute_name: str,
usd_attribute_name: str
@BigRoy
BigRoy / usd_compute_velocities.py
Created August 20, 2025 13:46
Using USD Python API compute velocities attribute (poor man's example)
from pxr import Usd, UsdGeom, Sdf, Vt, Gf
# Create a new stage in memory
stage =Usd.Stage.Open(r"path/to/file.usd")
fps = stage.GetFramesPerSecond() or 24.0 # default when not authored is 24
for prim in stage.Traverse():
if not prim.IsA(UsdGeom.PointBased):
continue
@BigRoy
BigRoy / hou_solaris_get_context_options_menu_items.py
Created July 21, 2025 15:17
Houdini Python script to get the menu items for configured Solaris Context Options
from typing import Union
import hou
import json
import textwrap
def exec_as_function(code):
"""Execute code similar to Houdini
- Single line evaluates like expression
@BigRoy
BigRoy / ayon_applications_find_invalid_environment_json.py
Last active July 15, 2025 22:46
Find invalid JSON environment entries in stored AYON applications settings
import ayon_api
import json
addon_name = "applications"
addons = ayon_api.get_addons_info()["addons"]
applications_addon = next(addon for addon in addons if addon["name"] == addon_name)
variants = ["production", "staging"] # ignore dev bundles for now
for addon_version, version_info in applications_addon["versions"].items():
if not version_info["hasSettings"]:
continue
@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.