Skip to content

Instantly share code, notes, and snippets.

View BigRoy's full-sized avatar

Roy Nieterau BigRoy

View GitHub Profile
@BigRoy
BigRoy / openpype_to_ayon_core.md
Last active April 25, 2024 16:42
OpenPype codebase refactor to AYON core

Transition code from OpenPype to Ayon Core

Refactor

  • openpype -> ayon_core
  • Loader plugins update method now takes context instead of representation argument | ynput/ayon-core#130
  • Loader plugins attribute families (list) -> product_types (set) | ynput/ayon-core#191
  • Creator plugins: family -> productType | ynput/ayon-core#113
  • Refactor OpenPypeModule -> AYONAddon | ynput/ayon-core#22
    • now in ayon_core.addon instead of ayon_core.modules
@BigRoy
BigRoy / resolve_get_media_pool_item_usage.py
Created February 28, 2024 16:51
Blackmagic Design Resolve Python API get all TimelineItems usage for a MediaPoolItem
def find_clip_usage(media_pool_item, project):
"""Return all Timeline Items in the project using the Media Pool Item.
Each entry in the list is a tuple of Timeline and TimelineItem so that
it's easy to know which Timeline the TimelineItem belongs to.
Arguments:
media_pool_item (MediaPoolItem): The Media Pool Item to search for.
project (Project): The resolve project the media pool item resides in.
@BigRoy
BigRoy / houdini_lop_get_houdini_editor_node_from_usd_shader.py
Created February 23, 2024 15:16
Houdini Solaris find the Houdini Editor Node for a Shader or Material in a Houdini Material Library
import os
import logging
from typing import List
import hou
import loputils
from pxr import Usd, UsdShade
log = logging.getLogger(__name__)
@BigRoy
BigRoy / houdini_lop_materiallibrary_get_material_to_houdini_node_mapping.py
Last active February 23, 2024 15:51
Houdini Solaris Material Library LOP get the USD Material Prim Path mapping to the Houdini Material node in the Material Library
import logging
from typing import Dict
import hou
log = logging.getLogger(__name__)
def get_material_library_paths(material_lib: hou.LopNode) -> Dict[str, str]:
"""Return Houdini material node path to USD path mapping
@BigRoy
BigRoy / houdini_lop_attributewrangle_reset_scale.py
Last active February 20, 2024 11:44
Houdini AttributeWrange LOP: remove any scaling - make sure primitive scale is {1, 1, 1}, for example useful for cameras.
// Remove any scaling from parent prims
matrix transform = usd_worldtransform(0, @primpath);
vector scale = cracktransform(0, 0, 2, {0, 0, 0}, transform);
if (scale != {1, 1, 1}) {
usd_addscale(0, @primpath, "remove_scale", 1 / scale);
}
@BigRoy
BigRoy / ayon_load_by_representation_id.py
Created February 8, 2024 12:57
AYON Pipeline - Load a representation container instance by representation id in Python
from openpype.pipeline.load.plugins import discover_loader_plugins
from openpype.pipeline.load.utils import loaders_from_representation, load_container
loader_name = "GpuCacheLoader"
representation_id = '6b7b5b6e-c677-11ee-b580-18c04d958ef6'
all_loaders = discover_loader_plugins()
loaders = loaders_from_representation(all_loaders, representation_id)
Loader = next((i for i in loaders if i.__name__ == loader_name), None)
@BigRoy
BigRoy / maya_connect_objects_to_nurbscurve_pointoncurveinfo.py
Created February 8, 2024 10:40
Maya: Connect Objects translation to param u on NurbsCurve via pointOnCurveInfo node.
"""Connect objects (transforms) to a nurbsCurve by pointOnCurve node.
Select the objects, then select the nurbsCurve last.
Run the script.
Voila.
Updated version of: https://polycount.com/discussion/161754/eye-rig-script-problem
"""
@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)
@BigRoy
BigRoy / maya_query_mesh_hard_edges.py
Created January 31, 2024 19:28
Maya get all hard edges (note that a mesh may still display smooth if e.g. it had locked normals)
from maya import cmds
import maya.api.OpenMaya as om
def get_fn_mesh(mesh):
sel = om.MSelectionList()
sel.add(mesh)
dag = sel.getDagPath(0)
return om.MFnMesh(dag)
hard_edged_meshes = []
@BigRoy
BigRoy / houdini_solaris_isolate_selected_debug_shading_shelf_button.py
Last active January 24, 2024 18:16
Houdini Solaris shader/render debug "isolate selected" type of behavior similar to Arnold Render View (use as shelf script - CTRL+ click disables it)
from typing import Tuple
import hou
import toolutils
from pxr import UsdShade, Sdf
POST_LAYER_NAME = "isolate_shaders"
# Prioritize outputs if there are multiple