Skip to content

Instantly share code, notes, and snippets.

Avatar

Roy Nieterau BigRoy

View GitHub Profile
@BigRoy
BigRoy / pyblish_debug_stepper.py
Last active Sep 30, 2022
Pyblish debug stepper - pauses between each plug-in process and shows the Context + Instances with their data at that point in time
View pyblish_debug_stepper.py
import pprint
import inspect
import html
import copy
import pyblish.api
from Qt import QtWidgets, QtCore, QtGui
TAB = 4* " "
@BigRoy
BigRoy / openpype_publishing_data.md
Last active Sep 29, 2022
Draft for the documentation on context/instance data during publishing
View openpype_publishing_data.md

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 / show_in_kitsu.py
Last active Sep 8, 2022
Untested psuedocode for "Show In Kitsu" launcher action for OpenPype
View show_in_kitsu.py
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 / maya_restart.py
Created Aug 25, 2022
Restart Maya from within Maya using Python script
View maya_restart.py
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 / maya_get_mesh_shells.py
Created Jun 20, 2022
Maya get faces of mesh per island or poly shell
View maya_get_mesh_shells.py
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 / openpype_v3_query_latest_versions.py
Created Jun 10, 2022
OpenPype v3 example queries for recently published versions and representation filepaths
View openpype_v3_query_latest_versions.py
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 / ffmpeg_overlay_video_snippet.py
Created May 20, 2022
Extracted from maya-capture-ui-cb's ffmpeg overlays to share the overall implementation details.
View ffmpeg_overlay_video_snippet.py
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 / maya_asShadingNode.py
Last active May 6, 2022
Maya set shading node classification on existing nodes like `maya.cmds.shadingNode` does for creation of new nodes
View maya_asShadingNode.py
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 / ragdoll_create_fixed_constraint_on_selected_marker.py
Created Feb 9, 2022
Create a Fixed Constraint on selected Maya Ragdoll Dynamics "rdMarker" by creating a duplicate marker with the same source transform that is kinematic
View ragdoll_create_fixed_constraint_on_selected_marker.py
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_cycle_evaluation_error.py
Created Jan 12, 2022
Maya check Cycle Errors more thoroughly where maya.cmds.cycleCheck(list=True) fails.
View maya_cycle_evaluation_error.py
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.