Skip to content

Instantly share code, notes, and snippets.

View BigRoy's full-sized avatar

Roy Nieterau BigRoy

View GitHub Profile
@BigRoy
BigRoy / usd_sdf_move_prim_spec.py
Last active March 16, 2026 22:03
USD API move prim spec including repathing relationships and connections to it and its children in a single Sdf Layer
from pxr import Sdf, Usd
LIST_ATTRS = ['addedItems', 'appendedItems', 'deletedItems', 'explicitItems',
'orderedItems', 'prependedItems']
def repath_properties(layer, old_path, new_path):
"""Re-path property relationship targets and attribute connections.
This will replace any relationship or connections from old path
@BigRoy
BigRoy / maya_remove_CgAbBlastPanelOptChangeCallback.py
Created August 8, 2019 09:50
Little snippet to remove "CgAbBlastPanelOptChangeCallback" error from Maya scene - // Error: line 1: Cannot find procedure "CgAbBlastPanelOptChangeCallback". //
"""
This will iterate all modelPanels and remove the "CgAbBlastPanelOptChangeCallback"
As such, after running this the following error should be fixed:
// Error: line 1: Cannot find procedure "CgAbBlastPanelOptChangeCallback". //
"""
from maya import cmds
for model_panel in cmds.getPanel(typ="modelPanel"):
@BigRoy
BigRoy / ayon_load_set_representation_colorspace.py
Created February 4, 2026 10:45
Quick 'n' dirty way to expose simple means to set a representation's colorspace. Run this in admin console in tray launcher, then when opening tray browser it should show an action to "Change Representation Colorspace" - use the OPTION BOX to set a new one.
import ayon_api
from ayon_core.lib import TextDef, UILabelDef
from ayon_core.pipeline import register_loader_plugin, LoaderPlugin
from ayon_core.pipeline.colorspace import get_ocio_config_colorspaces
from ayon_core.pipeline.load import LoadError
class ChangeColorspaceLoader(LoaderPlugin):
label = "Change Representation Colorspace"
product_types = ["*"]
@BigRoy
BigRoy / ayon_docker_notes.md
Last active February 4, 2026 09:19
Ayon docker, install, setup and management notes

Note these are not any official notes - just random scribbles

Bootstrap

Running bootstrap wont give you the latest dev versions, only whats been released on the bootstrap server by the ynput team.

Updating it from time to time is a good way to see what progress has been made in terms of addons etc. It shouldnt remove old addon version, only add the new ones. That way you can still use older addons should you need. You would need to create a new bundle to accommodate that.

@BigRoy
BigRoy / maya_cycle_evaluation_error.py
Created January 12, 2022 00:36
Maya check Cycle Errors more thoroughly where maya.cmds.cycleCheck(list=True) fails.
from maya import cmds
import contextlib
@contextlib.contextmanager
def capture_cycle_errors():
"""Capture the plugs in Cycle Error warnings.
During this context "Cycle on 'x' may not evaluate as expected"
are captured and 'x' is extracted as plugs in the yielded list.
@BigRoy
BigRoy / usdviewport_qt.py
Last active December 5, 2025 06:26
Example of how to embed a simple USD viewport in Qt application
"""
MIT License
Copyright (c) 2019 Roy Nieterau
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@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