Skip to content

Instantly share code, notes, and snippets.

View BigRoy's full-sized avatar

Roy Nieterau BigRoy

View GitHub Profile
@BigRoy
BigRoy / alembic_has_any_shapes.py
Last active May 20, 2024 20:31
Python script using Alembic api to detect whether an .abc file contains any shapes.
import alembic
def any_shapes_in_alembic(filename):
"""Return whether Alembic file contains any shape/geometry.
Arguments:
filename (str): Full path to Alembic archive to read.
Returns:
bool: Whether Alembic file contains geometry.
@BigRoy
BigRoy / alembic_get_inclusive_matrix.py
Last active January 10, 2021 22:57
Example using Alembic python api to get the full inclusive matrix for objects in the .abc file.
import alembic.Abc
from alembic.AbcGeom import IXform
kWrapExisting = alembic.Abc.WrapExistingFlag.kWrapExisting
def get_matrix(obj):
if not IXform.matches(obj.getHeader()):
raise TypeError("Object is not an xform: {0}".format(obj))
@BigRoy
BigRoy / blender28_run_qt_ui.py
Created August 1, 2019 10:04
Simple example of running a Qt interface in Blender 2.8 without blocking Blender.
import bpy
from PyQt5 import QtWidgets
class QtModalOperator(bpy.types.Operator):
"""A base class for Operators that run a Qt interface."""
def modal(self, context, event):
if self._app:
@BigRoy
BigRoy / avalon_dependencies_NodeGraphQt_prototype.py
Created August 6, 2019 13:29
A very quick and dirty simple prototype to showcase the NodeGraphQt as a possibility for visualizing input/output dependencies
import os
import sys
from NodeGraphQt import (
NodeGraph,
BaseNode,
)
from avalon import io, style
@BigRoy
BigRoy / maya_get_visible_in_frame_range.py
Last active February 3, 2023 15:09
An optimized Maya function that returns the dag node names that are at least visible once on whole frames between requested start and end frame, this accounts for animated visibilities of the nodes and their parents.
import maya.api.OpenMaya as om2
import maya.cmds as mc
import contextlib
from colorbleed.maya.lib import iter_parents
@contextlib.contextmanager
def maintained_time():
ct = cmds.currentTime(query=True)
@BigRoy
BigRoy / maya_remove_CgAbBlastPanelOptChangeCallback.py
Created August 8, 2019 09:50
Little snippet to remove "CgAbBlastPanelOptChangeCallback" error from Maya scene - // Error: line 1: Cannot find procedure "CgAbBlastPanelOptChangeCallback". //
"""
This will iterate all modelPanels and remove the "CgAbBlastPanelOptChangeCallback"
As such, after running this the following error should be fixed:
// Error: line 1: Cannot find procedure "CgAbBlastPanelOptChangeCallback". //
"""
from maya import cmds
for model_panel in cmds.getPanel(typ="modelPanel"):
@BigRoy
BigRoy / maya_renderlayer_fix_unable_to_duplicate.py
Created August 28, 2019 16:55
Fix Maya legacy renderlayer being unable to duplicate (it doesn't show up correctly, but it does create a new renderLayer node visible when Show DAG nodes only is disabled)
# Fix Maya bug where you cannot duplicate a renderlayer correctly bug
# This is with Legacy Renderlayers, not Render Setup.
# Bug has been found in both Maya 2018 + 2019
import maya.cmds as mc
# Recreate all renderlayer overrides (.adjustments)
for layer in mc.ls(type="renderLayer"):
attr = layer + ".adjustments"
@BigRoy
BigRoy / avalon_maya_host_ls_optimizations.py
Created September 26, 2019 17:33
Avalon Maya host ls() query optimization tests
from maya import cmds
import maya.api.OpenMaya as om
from avalon.pipeline import AVALON_CONTAINER_ID
import avalon.maya.pipeline
# Current implementation
ls = avalon.maya.pipeline._ls
@BigRoy
BigRoy / blender2019_conference.md
Last active October 25, 2019 09:31
Breakdown of Blender 2019 Live stream conference moments https://www.youtube.com/watch?v=ioAZgnSh7X4

Blender Conference 2019 - LIVE stream breakdown

Stream: https://www.youtube.com/watch?v=ioAZgnSh7X4

Below is a rough breakdown of moments/times of talks in the video. Feel free to comment with more thorough notes you might have taken during the talk or video. Plus, comments that include other timings of talks that are still missing are more than welcome!

Please be aware that most of these talks are also uploaded as separate videos to the Blender youtube channel almost instantly after the talk finishes. I'll link the title of each to the separate video. Here is the full playlist per video

@BigRoy
BigRoy / usdviewport_qt.py
Last active October 26, 2024 16:32
Example of how to embed a simple USD viewport in Qt application
"""
MIT License
Copyright (c) 2019 Roy Nieterau
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is