Skip to content

Instantly share code, notes, and snippets.

View BigRoy's full-sized avatar

Roy Nieterau BigRoy

View GitHub Profile
@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 / 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 / maya_asShadingNode.py
Last active January 16, 2023 11:07
Maya set shading node classification on existing nodes like `maya.cmds.shadingNode` does for creation of new nodes
from maya import cmds
def asShadingNode(node, **kwargs):
"""Set shading node classification on existing nodes.
Like `maya.cmds.shadingNode` does on creation of nodes
this command can add or remove a shading node classification.
It matches the same argument names of `maya.cmds.shadingNode`
@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 / openpype_v3_query_latest_versions.py
Created June 10, 2022 08:03
OpenPype v3 example queries for recently published versions and representation filepaths
from openpype.pipeline import legacy_io
import datetime
# This is what OpenPype v3 uses for the date it stores on versions (reference)
"""
def get_formatted_current_time():
return datetime.datetime.now().strftime(
"%Y%m%dT%H%M%SZ"
)
"""
@BigRoy
BigRoy / maya_get_mesh_shells.py
Created June 20, 2022 13:54
Maya get faces of mesh per island or poly shell
from maya import cmds
def get_shells(mesh, as_selection_string=True):
"""Return faces per shell of mesh"""
num_shells = cmds.polyEvaluate(mesh, shell=True)
num_faces = cmds.polyEvaluate(mesh, face=True)
unprocessed = set(range(num_faces))
@BigRoy
BigRoy / maya_restart.py
Created August 25, 2022 12:47
Restart Maya from within Maya using Python script
import subprocess
import sys
import os
from maya import cmds
current_file = cmds.file(query=True, sceneName=True)
args = [sys.executable]
if current_file and os.path.exists(current_file):
args.append("-file")
args.append(current_file)
@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_publishing_data.md
Last active September 29, 2022 21:43
Draft for the documentation on context/instance data during publishing

NOTE

This is clearly a work in progress

Context Data

Example of content in a Maya publish of context.data

key type description example value
@BigRoy
BigRoy / pyblish_debug_stepper.py
Last active December 9, 2024 13:35
Pyblish debug stepper - pauses between each plug-in process and shows the Context + Instances with their data at that point in time
import pprint
import inspect
import html
import copy
import pyblish.api
from Qt import QtWidgets, QtCore, QtGui
TAB = 4* " "