Skip to content

Instantly share code, notes, and snippets.

View BigRoy's full-sized avatar

Roy Nieterau BigRoy

View GitHub Profile
@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 / hou18_solaris_python_addremove_usd_outputprocessors.py
Created January 29, 2020 02:34
Houdini 18 Solaris Add and Remove USD Rop node Output Processors with Python
import contextlib
import hou
def add_output_processor(ropnode, processor):
"""Add USD Output Processor to USD Rop node.
Args:
ropnode (hou.RopNode): The USD Rop node.
processor (str): The output processor name. This is the basename of
the python file that contains the Houdini USD Output Processor.
@BigRoy
BigRoy / maya_snap_objects_to_target_vertex.py
Created March 20, 2020 09:41
Snap multiple objects by vertex index to target vertex.
"""Snap multiple objects by vertex index to target vertex.
1. Select all objects you want to snap
2. Add the target vertex to your selection.
3. Run script
Make sure each object has the same topological order because
this just simply snaps the same vertex number of each object
to the selected target vertex.
@BigRoy
BigRoy / maya_list_all_children_with_instances.py
Last active February 18, 2025 07:05
Autodesk Maya Python list or query all children including each instance
"""When using maya.cmds.listRelatives with allDescendents=True it will only return the first instanced child.
Below are some example functions that correctly return all instanced children where they are "somewhat" optimized to rapidly return a result as opposed to slow recursive queries.
"""
import maya.api.OpenMaya as om
from maya import cmds
import time
import re
@BigRoy
BigRoy / print_alembic_shape_attributes.py
Created September 22, 2020 14:43
Debug print out Alembic PolyMesh attributes
import alembic
def _print_properties(property, depth=1):
# Property name
print ("\t" * depth) + property.getName()
# Metadata
metadata = property.getMetaData()
if metadata.size():
@BigRoy
BigRoy / maya_usd_define_primitive.py
Last active February 14, 2025 10:12
Maya USD define Usd Primitives on the stage using Python for MayaUsdProxyShape
# Tested December 21st, 2020
# This is just a test example of how one could use the USD Api against a mayaUsdProxyShape and its USD stage.
# Note: The outliner doesn't really like it when you change the stage
# so you might need to toggle shape display off and on to get it to update.
import mayaUsd
from maya import cmds
from pxr import Usd, UsdGeom
shape = cmds.ls(type="mayaUsdProxyShape", long=True)[0] # make sure to use long full paths
stage = mayaUsd.ufe.getStage('|world' + shape)
@BigRoy
BigRoy / maya_rendersetup_get_attr_value_in_layer.py
Last active February 27, 2024 03:51
Query the attribute value in Maya Render Setup layer without switching layer
from maya import cmds
import maya.api.OpenMaya as om
import pymel.core as pm
import maya.app.renderSetup.model.utils as utils
from maya.app.renderSetup.model import (
override,
selector,
collection,
renderLayer,
@BigRoy
BigRoy / maya_toggle_rendersetup_nodes_in_editors.py
Created January 25, 2021 09:41
Maya Render Setup has the option to disable showing Renderlayer / Rendersetup nodes visibility in Outliner and other editors. This script allows to toggle that easily, even when currently in legacy renderlayer mode whilst the option is hidden away.
from maya import cmds
import maya.app.renderSetup.model.initialize as init
# Get node types from Render Setup
node_types = init.renderSetupNodeNamesToShowInOutliner
display = True
for node_type in node_types:
cmds.setNodeTypeFlag(node_type, display=display)
@BigRoy
BigRoy / maya_export_nodes_from_render_setup_layer.py
Created February 3, 2021 11:41
Export Maya nodes from Render Setup layer as if flattened in that layer instead of exporting the defaultRenderLayer as Maya forces by default
import os
import contextlib
from maya import cmds
from maya.app.renderSetup.model import renderSetup
# Custom library functions, see: https://github.com/Colorbleed/colorbleed-config
from colorbleed.maya import lib
from colorbleed.lib import pairwise
@BigRoy
BigRoy / avalon_load_by_cbid.py
Created February 8, 2021 16:39
Avalon example for colorbleed-config on how to load latest version of an asset's `modelDefault` solely from the `cbId` attribute.
# Example on how to load latest `modelDefault` of an asset by `cbId` value using `AbcLoader` (alembic)
import avalon.io as io
import avalon.api as api
from maya import cmds
node = "my_node"
cbid = cmds.getAttr("%s.cbId" % node)
# Get asset object id from cbId
object_id = cbid.split(":", 1)[0] # The part before the : is the asset id