Skip to content

Instantly share code, notes, and snippets.

View BigRoy's full-sized avatar

Roy Nieterau BigRoy

View GitHub Profile
@BigRoy
BigRoy / integrate_asset_simple.py
Created February 27, 2016 12:32
A Pyblish integrator draft for Pyblish Magenta that integrates files into a "publish" folder next to the current file.
import os
import shutil
import pyblish.api
import pyblish.util
import pyblish_magenta.api
class IntegrateAssetsSimple(pyblish.api.Integrator):
"""Name and position instances on disk for shots
@BigRoy
BigRoy / fusion_print_selected_tool_inputs.py
Last active July 25, 2016 20:44
Debug print selected tool inputs in Fusion
# For each selected tool
tools = comp.GetToolList(True).values()
for tool in tools:
print tool.Name
# For each input
inputs = tool.GetInputList().values()
for input in inputs:
name = input.Name # ui friendly name
@BigRoy
BigRoy / qt_qcolumnview_selection.py
Created March 8, 2017 14:14
Set QColumnView selection (and update the columns)
import sys
import os
from Qt import QtWidgets, QtCore, QtGui
def main():
app = QtWidgets.QApplication(sys.argv)
path = r"C:\test\subfolder\file.txt"
@BigRoy
BigRoy / mpxfiletranslator_crash_example.py
Created October 19, 2017 13:49
This is a custom MPxFileTranslator that can be loaded as plug-in into Maya. With this loaded as plug-in you can reference any `.txt` file on disk. To make this work save a `.ma` scene next to the text file with the same name and reference the txt file. What should happen is that the `.ma` should be loaded three times within a single reference no…
"""This is a custom MPxFileTranslator that can be loaded as plug-in into Maya.
With this loaded as plug-in you can reference any `.txt` file on disk.
To make this work save a `.ma` scene next to the text file with the same name
and reference the txt file. What should happen is that the `.ma` should be
loaded three times within a single reference node in Maya.
Note: it crashes in Maya 2018 when saving the scene and then reopening the scene.
"""
@BigRoy
BigRoy / maya_list_file_node_sequence_files.py
Created February 27, 2018 14:46
For maya file paths list all files that match a pattern like UDIM patterns or file sequence patterns
def seq_to_glob(path):
"""Takes an image sequence path and returns it in glob format,
with the frame number replaced by a '*'.
Image sequences may be numerical sequences, e.g. /path/to/file.1001.exr
will return as /path/to/file.*.exr.
Image sequences may also use tokens to denote sequences, e.g.
/path/to/texture.<UDIM>.tif will return as /path/to/texture.*.tif.
@BigRoy
BigRoy / avalon_dependencies.py
Last active June 7, 2019 13:09
Example pseudocode to collect dependencies and publish them in Avalon database
"""Example pseudocode to collect dependencies and publish them in Avalon database.
- Collect dependencies of what is included/used as representation at time of publish (example shows Maya implementation)
- Store in database under version[data][dependencies]
- Debug print dependencies for a representation (see psuedocode at end)
"""
import maya.cmds as mc
import avalon.api as api
@BigRoy
BigRoy / maya_get_shader_overrides_in_renderlayer.py
Created June 11, 2019 09:05
Simple example of how to get shader assignment overrides in renderlayers in Maya. (This is built for renderlayers, *not!* for render setup)
import maya.cmds as cmds
def get_shader_overrides_in_renderlayer(layer):
"""Return shader assignment overrides in renderlayer"""
attr = "{layer}.outAdjustments".format(layer=layer)
indices = cmds.getAttr(attr, multiIndices=True)
overrides = {}
for index in indices:
@BigRoy
BigRoy / maya_get_shader_in_layer.py
Created June 11, 2019 12:30
For a specific shape or mesh get the assigned shader in a specific renderlayer without switching to that layer.
import maya.cmds as cmds
def get_shader_in_layer(node, layer):
"""Return the assigned shader in a renderlayer without switching layers.
This has been developed and tested for Legacy Renderlayers and *not* for
Render Setup.
Returns:
list: The list of assigned shaders in the given layer.
@BigRoy
BigRoy / publish_instances_on_farm.py
Created July 12, 2019 08:44
A Deadline job script that will trigger a Pyblish publish with only the instances by name defined in env. var. PYBLISH_ACTIVE_INSTANCES
try:
import logging
import pyblish.api
import pyblish.util
except ImportError as exc:
# Ensure Deadline fails by output an error that contains "Fatal Error:"
raise ImportError("Fatal Error: %s" % exc)
handler = logging.basicConfig()
@BigRoy
BigRoy / avalon_compare_alembic_hierarchy_diferences.py
Created July 30, 2019 13:08
An example gist that shows how to compare different the hierarchy paths between published Alembic files and print out the differences. This is a more elaborate example of a prototype I wrote here: https://github.com/getavalon/core/issues/101#issuecomment-516337513
from avalon import api
from avalon import io
import alembic.Abc
def get_alembic_paths(filename):
"""Return all full hierarchy paths from alembic file"""
# Normalize alembic path
path = os.path.normpath(filename)