Skip to content

Instantly share code, notes, and snippets.

View davidlatwe's full-sized avatar
:shipit:
Awesome

David Lai davidlatwe

:shipit:
Awesome
View GitHub Profile
@BigRoy
BigRoy / pyblish_debug_stepper.py
Last active September 6, 2024 17:41
Pyblish debug stepper - pauses between each plug-in process and shows the Context + Instances with their data at that point in time
import pprint
import inspect
import html
import copy
import pyblish.api
from Qt import QtWidgets, QtCore, QtGui
TAB = 4* " "
@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,
// Maya Mel UI Configuration File.Maya Mel UI Configuration File..
//
//
// This script is machine generated. Edit at your own risk.
//
//
////////////////////////////////////////////////////////////////////
global proc UI_Mel_Configuration_think(){
string $localized_resources_path = `getenv MAYA_LOCATION`+("/resources/l10n/");
string $all_file[]=`getFileList -folder $localized_resources_path`;
@BigRoy
BigRoy / usdviewport_qt.py
Last active August 19, 2024 10:07
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
@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_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 / 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 / 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 / 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)
@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.