Skip to content

Instantly share code, notes, and snippets.

View bohdon's full-sized avatar

Bohdon Sayre bohdon

View GitHub Profile
@bohdon
bohdon / clean_p4p_cache.py
Last active October 16, 2024 14:56
Clean a p4proxy cache to remove unnecessary files and free up disk space.
from __future__ import annotations
import logging
import os
import re
import time
import click
LOG = logging.getLogger(__name__)
@bohdon
bohdon / notify.py
Created August 22, 2024 13:49
A simple notify script that sends a message to a webhook url, designed for Discord.
from __future__ import annotations
import logging
import os
import click
import requests
LOG = logging.getLogger(__name__)
@bohdon
bohdon / aggregate_senders.gs
Last active December 25, 2023 20:29
Google app script to aggregate email sender domains by count for finding who sends you the most email.
/**
* A Google app script that gathers threads from your inbox and sorts the
* sender domains by quantity of emails, then outputs to a spreadsheet.
*/
/** Given a sender, return just the domain of the email address. */
function getSenderDomain(sender) {
// parse from '"My Name" <[email protected]>'
var regex = RegExp("(?:<.*@)([^>]*)");
var matches = regex.exec(sender);
@bohdon
bohdon / p4fw_create_standard_client.py
Created April 22, 2023 14:20
Create a standard p4 workspace using the primary root, sgtk user, and current host name.
# Create a standard workspace using the primary root, sgtk user, and current host name.
# Intended to be run in the Python Console from ShotGrid Desktop.
import os
import socket
from pathlib import Path
import sgtk
p4fw = sgtk.platform.framework.load_framework(engine, engine.get_env(), 'tk-framework-perforce2_v0.x.x')
root_path = tk.roots['primary']
@bohdon
bohdon / quill_anim_import.py
Created April 10, 2023 20:29
Imports quill animation into maya directly from the Quill.json.
import sys
import json
def import_anim(path: str):
with open(path) as fp:
data = json.load(fp)
all_layers = get_layers(data)
@bohdon
bohdon / sgtk_app_bg_shotgun_request.py
Last active April 6, 2023 17:03
ShotGrid Toolkit App background shotgun request.
shotgun_data = sgtk.platform.import_framework("tk-framework-shotgunutils", "shotgun_data")
shotgun_globals = sgtk.platform.import_framework("tk-framework-shotgunutils", "shotgun_globals")
shotgun_model = sgtk.platform.import_framework("tk-framework-shotgunutils", "shotgun_model")
task_manager = sgtk.platform.import_framework("tk-framework-shotgunutils", "task_manager")
class MyWidget(QtGui.QWidget):
def __init__(self, parent):
super().__init__(parent)
self._task_manager = task_manager.BackgroundTaskManager(self)
@bohdon
bohdon / unlock_soft_edge_normals.py
Last active January 24, 2023 21:08
Unlock normals on a mesh in Maya, but detect and preserve soft edges.
import pymel.core as pm
def is_soft_edge(edge):
vtx_faces = pm.polyListComponentConversion(edge, fromEdge=True, toVertexFace=True)
expanded_vtx_faces = pm.filterExpand(vtx_faces, expand=True, selectionMask=70)
vtx_faces_by_vtx = dict()
for vtx_face in expanded_vtx_faces:
vtx = pm.polyListComponentConversion(vtx_face, fromVertexFace=True, toVertex=True)
vtx_str = str(vtx)
@bohdon
bohdon / center_twist_joint.py
Created January 24, 2023 19:17
Center a twist joint between it's parent joint and an end joint in Maya.
import pymel.core as pm
def center_twist_joint(twist_joint, end_joint):
"""
Center a twist joint between it's parent and an end joint
"""
root_joint = twist_joint.getParent()
center = (root_joint.getTranslation(space='world') + end_joint.getTranslation(space='world')) / 2.0
twist_joint.setTranslation(center, space='world')
@bohdon
bohdon / sort_nodes.py
Created January 24, 2023 15:49
Sort the selected Maya nodes by name.
import pymel.core as pm
def sort_by_name(nodes):
# get sorted list of nodes
sorted_nodes = sorted(nodes)
for node in sorted_nodes:
pm.reorder(node, back=True)
@bohdon
bohdon / shotgrid_boostrap_maya.py
Created July 11, 2022 14:58
Bootstraps ShotGrid in Maya from a standalone launch.
import sys
# assumes a specific tk-core version is installed, other tk-core acquisition methods are available
tk_core_path = "C:/Program Files/Shotgun/Resources/Desktop/Python/bundle_cache/app_store/tk-core/v0.20.12/python"
# the project id to use for the context
project_id = 369
sys.path.append(tk_core_path)
import sgtk