Skip to content

Instantly share code, notes, and snippets.

View BigRoy's full-sized avatar

Roy Nieterau BigRoy

View GitHub Profile
import maya.OpenMaya as om
import maya.cmds as mc
import uuid
def ensure_id(node):
"""Add a uuid attribute on the given node with a unique value.
Skips nodes that already have the attribute, unless when used upon duplicating.
Maya temporarily assigns the prefix '__PrenotatoPerDuplicare_' so we use that
@BigRoy
BigRoy / avalon_cgwire_qtazu_link.py
Last active February 27, 2024 23:21
Example API for linking CG-Wire with Avalon with Qtazu
@BigRoy
BigRoy / ragdoll_create_fixed_constraint_on_selected_marker.py
Created February 9, 2022 17:12
Create a Fixed Constraint on selected Maya Ragdoll Dynamics "rdMarker" by creating a duplicate marker with the same source transform that is kinematic
from ragdoll.vendor import cmdx
from ragdoll import commands, interactive
def fix_marker_in_place(marker):
source = marker["sourceTransform"].input()
solver = commands._find_solver(marker)
start_time = solver["_startTime"].asTime()
start_frame = cmdx.frame(start_time)
@BigRoy
BigRoy / ffmpeg_overlay_video_snippet.py
Created May 20, 2022 10:21
Extracted from maya-capture-ui-cb's ffmpeg overlays to share the overall implementation details.
import logging
import subprocess
from datetime import datetime
import os
import re
import tempfile
log = logging.getLogger(__name__)
# Locate ffmpeg if full path provided, otherwise use ffmpeg executable name
@BigRoy
BigRoy / show_in_kitsu.py
Last active February 27, 2024 23:20
Untested psuedocode for "Show In Kitsu" launcher action for OpenPype
import webbrowser
from openpype.pipeline import LauncherAction
from openpype.modules import ModulesManager
from openpype.client import get_project, get_asset_by_name
class ShowInKitsu(LauncherAction):
name = "showinkitsu"
label = "Show in Kitsu"
@BigRoy
BigRoy / openpype_substancepainter_python_script_editor_plugin.py
Created January 12, 2023 15:57
Simple quick and dirty Substance Painter Plug-in which adds a Python Script Editor using OpenPype's scripting console
from PySide2 import QtCore, QtWidgets
import substance_painter.ui
try:
from openpype_modules.python_console_interpreter.window import PythonInterpreterWidget # noqa
except ModuleNotFoundError:
from openpype.modules.python_console_interpreter.window import PythonInterpreterWidget # noqa
WIDGET = None
ACTION = None
@BigRoy
BigRoy / usd_list_layer_edits_editor.py
Last active February 27, 2024 23:16
Quick and dirty "List USD Layer Edits" to allow removal of Sdf.PrimSpec, Sdf.PropertySpec, Sdf.AttributeSpec, Sdf.RelationshipSpec through a Python Qt interface
from PySide2 import QtCore, QtWidgets, QtGui
from pxr import Usd, Tf, Sdf
# See: https://github.com/PixarAnimationStudios/OpenUSD/blob/release/pxr/usd/sdf/fileIO_Common.cpp#L879-L892
SPECIFIER_LABEL = {
Sdf.SpecifierDef: "def",
Sdf.SpecifierOver: "over",
Sdf.SpecifierClass: "abstract"
}
@BigRoy
BigRoy / usd_get_registered_prim_type_schemas.py
Created November 19, 2023 22:59
Get all registered prim types to create by a nice plug-in grouping
from pxr import Usd, Plug, Tf
from collections import defaultdict
NICE_NAMES = {
"usdGeom": "Geometry",
"usdLux": "Lighting",
"mayaUsd_Schemas": "Maya Reference",
"usdMedia": "Media",
"usdRender": "Render",
"usdRi": "RenderMan",
@BigRoy
BigRoy / maya_usd_rise_vfx_create_default_assembly_rig_setup_example.py
Created December 27, 2023 17:23
Create Default Assembly Rig Setup as shown in How RISE VFX Reached New Creative Heights with USD in Maya talk
"""Create Default Assembly Rig Setup as shown in How RISE VFX Reached New Creative Heights with USD in Maya talk
See: https://youtu.be/8UIW-g1_heg?t=1902
"""
import pxr
import ufe
import pymel.core as pm
from mayaUsd import lib as mayaUsdLib
USD_SCHEMA = "UsdSchemaBase"
@BigRoy
BigRoy / usd_python_list_all_used_assets.py
Last active February 27, 2024 23:14
USD find all used assets in Stage or Layer using Python - e.g. findin all used textures
from pxr import UsdUtils, Sdf
stage = hou.pwd().editableStage()
# Given a Sdf.Layer you can use UsdUtils.ComputeAllDependencies
# which returns the layers, assets and any unresolved paths
layer = stage.Flatten()
layers, assets, unresolved_paths = UsdUtils.ComputeAllDependencies(layer.identifier)
for path in assets:
print(path)