Skip to content

Instantly share code, notes, and snippets.

View BigRoy's full-sized avatar

Roy Nieterau BigRoy

View GitHub Profile
@BigRoy
BigRoy / maya_script_editor_word_wrap.py
Created November 14, 2024 11:21
Force enable Word Wrap in Maya's script editor output
import maya.OpenMayaUI as mui
import shiboken2
from PySide2 import QtWidgets
# <-- get maya main window QMainWindow -->
ptr = mui.MQtUtil.mainWindow()
main_window = shiboken2.wrapInstance(int(ptr), QtWidgets.QMainWindow)
# <-- set wordWrap on script editor feedback field -->
cmdScrollFieldReporter = main_window.findChild(QtWidgets.QPlainTextEdit, "cmdScrollFieldReporter1")
@BigRoy
BigRoy / maya_export_chaser_filter_properties.py
Last active November 13, 2024 23:22
Maya USD Export Chaser to filter properties using SideFX-Houdini like parameter pattern matching
import re
import logging
from typing import List
import mayaUsd.lib as mayaUsdLib
from pxr import Sdf
def log_errors(fn):
"""Decorator to log errors on error"""
@BigRoy
BigRoy / ayon_print_settings_change_event_diffs.py
Last active November 6, 2024 00:15
AYON debug print settings changes
import json
import difflib
import ayon_api
amount = 10
for event_ in ayon_api.get_events(
topics={"settings.changed"},
# Set more filters if needed
# newer_than="isoformat-date",
@BigRoy
BigRoy / ayon_python_api_create_folders_and_tasks.py
Created October 30, 2024 19:16
AYON simple create folders and task via Python API example
from ayon_core.pipeline import get_current_project_name
import ayon_api
from ayon_api.entity_hub import EntityHub
project_name = get_current_project_name()
hub = EntityHub(project_name)
for folder_name in ["asset1", "asset2"]:
folder_entity = hub.add_new_folder(
folder_type="Shot", # folder type must exist in project
@BigRoy
BigRoy / ayon_debug_print_all_pyblish_plugins_for_family.py
Created October 14, 2024 15:08
AYON Print all pyblish publish plugins targeting a particular 'family' of the publish instance (usually also the same as the product type)
from ayon_core.pipeline import registered_host
from ayon_core.pipeline.create import CreateContext
import pyblish.api
family = "pointcache"
host = registered_host()
context = CreateContext(host)
plugins = pyblish.api.plugins_by_family(context.publish_plugins, family)
for plugin in plugins:
@BigRoy
BigRoy / maya_shape_components_expand.md
Last active September 13, 2024 07:02
Maya shapes with components are returned as "transform.component"

When doing face assignments or other component members into a set and then query cmds.sets(my_set, query=True) you get the members like:

  • pCube1.f[0:4]

Instead of

  • pCubeShape1.f[0:4]

For whatever reason someone thought it would be nice to make it look as if the components are on the transform instead of shape. Does anyone know a maya command to expand that to the shape?

@BigRoy
BigRoy / ayon_publisher_report_json_to_time_spent.py
Created July 30, 2024 16:02
OpenPype / AYON publisher json report get timings printout in seconds
import json
path = r"C:\Users\User\Downloads\publish-report-240730-17-33.json"
with open(path, "r") as f:
data = json.load(f)
for plugin_data in data["plugins_data"]:
label = plugin_data["label"]
@BigRoy
BigRoy / ayon_set_version_status.py
Created July 23, 2024 23:14
AYON - Set status for versions
"""WARNING! Set random status for all your versions in the project."""
import random
from ayon_core.pipeline import get_current_project_name
from ayon_api import get_project, get_versions
from ayon_api.operations import OperationsSession
project_name = get_current_project_name()
@BigRoy
BigRoy / openpype_to_ayon_core.md
Last active August 29, 2024 16:03
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.