Skip to content

Instantly share code, notes, and snippets.

View BigRoy's full-sized avatar

Roy Nieterau BigRoy

View GitHub Profile
@BigRoy
BigRoy / openpype_get_thumbnail.py
Created October 25, 2023 12:40
OpenPype get thumbnail for an entity
from openpype.pipeline.thumbnail import get_thumbnail_binary
from openpype.client import get_thumbnail_id_from_source, get_thumbnail
def get_entity_thumbnail(project_name, entity_id, entity_type):
thumbnail_id = get_thumbnail_id_from_source(project_name, entity_type, entity_id)
if not thumbnail_id:
return
thumbnail_entity = get_thumbnail(project_name, thumbnail_id, entity_type, entity_id)
if not thumbnail_entity:
@BigRoy
BigRoy / maya_usd_import_chaser_cbId_to_transform.py
Created October 19, 2023 13:45
Maya USD Import Chaser in Python to import `primvars:cbId_transform` attribute to the transform as `cbId` instead of as attribute on the shape
import logging
import mayaUsd.lib as mayaUsdLib
from maya import cmds
import maya.api.OpenMaya as OpenMaya
def create_cbid_attr(default_value):
default = OpenMaya.MFnStringData().create(default_value)
return OpenMaya.MFnTypedAttribute().create("cbId",
@BigRoy
BigRoy / maya_usd_ufe_material_selection_to_bound_objects.py
Last active October 11, 2023 07:05
Convert Maya USD Ufe Material selection to bound objects
from maya import cmds
import mayaUsd.ufe
from pxr import Usd, UsdShade
from collections import defaultdict
def pairwise(iterable):
it = iter(iterable)
return zip(it, it)
@BigRoy
BigRoy / maya_usd_ufe_geometry_selection_to_bound_materials.py
Last active October 12, 2023 04:40
Convert Maya USD Ufe Geometry selection to bound materials
from maya import cmds
import mayaUsd.ufe
from pxr import Usd, UsdShade
def pairwise(iterable):
it = iter(iterable)
return zip(it, it)
@BigRoy
BigRoy / example.json
Last active October 5, 2023 15:29
OpenPype JSON Publish Data
{
"asset": "ASSET_NAME",
"comment": "",
"deadline_publish_job_id": "651ea743d5ea807051ce62e1",
"fps": 25.0,
"frameEnd": 1250,
"frameStart": 1001,
"instances": [
{
"asset": "ASSET_NAME",
@BigRoy
BigRoy / openpype_show_context_data_loader.py
Created September 28, 2023 12:20
OpenPype / AYON debug loader to list all context data as json
import json
from openpype.pipeline import load
from openpype.style import load_stylesheet
class ShowContextData(load.LoaderPlugin):
"""Debug context data of representation"""
families = ["*"]
@BigRoy
BigRoy / maya_spaghetti_code_set_numbered_aliases.py
Created September 27, 2023 21:07
Set numbered aliases for all attributes on all nodes in maya
import math; import itertools as i; from itertools import chain as j
import maya.cmds as __
__._ = lambda _: chr(int(math.sqrt(_)+140//3))
__.__ = __.setAttr, __.listAttr, __.ls, __.aliasAttr
__._._ = 2601, 4900, 4900, 4624, 3481, 2704, 5041, 4900, 3025, 361, 3844, 3481, 2601, 4761
___ = __.__[2](dag=1)
____ = list({k: 0 for k in (__.__[1](___))})
____ = tuple(j.from_iterable(zip(i.count(), ____)))
_ = lambda _______: __.__[0](f"{_______}.aal", ____, type=''.join(map(__._, __._._)))
_.__ = lambda ______________: __.__[-1]("eispoo", f"{______________}.{__.__[1](______________, scalar=1)[0]}")
@BigRoy
BigRoy / hou_set_node_thumbnail.py
Created September 27, 2023 09:29
Houdini set node image thumbnail (NetworkView background image) and attach / link it to the node through Python
import hou
import contextlib
@contextlib.contextmanager
def editor_at_node(node, pane_tab_type=hou.paneTabType.NetworkEditor):
editor = hou.ui.paneTabOfType(pane_tab_type)
original_pwd = editor.pwd()
try:
@BigRoy
BigRoy / usd_list_layer_edits_editor.py
Last active November 7, 2024 15:42
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 / maya_query_holes_mesh.py
Created August 24, 2023 20:09
Maya find meshes with holes in them (that are not watertight) by checking if any edge is a boundary edge (not connected to two faces)
import maya.api.OpenMaya as om
from maya import cmds
def has_boundaries(mesh):
sel = om.MSelectionList()
sel.add(mesh)
dag = sel.getDagPath(0)
it = om.MItMeshEdge(dag)
while not it.isDone():