Skip to content

Instantly share code, notes, and snippets.

View bohdon's full-sized avatar

Bohdon Sayre bohdon

View GitHub Profile
@bohdon
bohdon / snap_ctls_to_joints.py
Last active August 23, 2021 20:59
Maya snippet to snap controls to joints, update CONTROL_JOINT_MAP with your own mappings
import pymel.core as pm
def snap_ctls_to_joints(ctl_joint_map):
for ctl_name, joint_name in CONTROL_JOINT_MAP.items():
ctl = pm.PyNode(ctl_name)
joint = pm.PyNode(joint_name)
ctl.setMatrix(joint.wm.get(), worldSpace=True)
CONTROL_JOINT_MAP = {
@bohdon
bohdon / p4_verify_case.py
Created July 3, 2021 00:11
A util for verifying and applying case consistency for local files and folders in a perforce workspace
#! python
"""
Util for verifying that the case of local files and folders
matches the case of files synced from perforce.
"""
import click
import yaml
import os
@bohdon
bohdon / p4_find_haves.py
Last active March 17, 2021 17:54
Find all workspaces in p4 that have any files in a depot path
#! python
import os
import click
import P4
from pathlib import Path
from typing import Set
@click.command()
@bohdon
bohdon / arnoldstatmem.py
Last active January 31, 2021 23:37
Print memory related stats from an arnold stats file
"""
Usage:
$ python arnoldstatmem.py arnold_stats.1.json
"""
import os
import json
import fnmatch
import sys
@bohdon
bohdon / p4-have.sh
Created January 15, 2021 16:09
Get the result of p4 have with only depot files, for use in piping to additional p4 commands
#!/bin/bash
p4 have $1 | grep -Eo '//.*#[[:digit:]]+'
@bohdon
bohdon / p4-flush-have.sh
Last active January 15, 2021 16:16
Flush the have list for a workspace in perforce
#!/bin/bash
# add -n after flush to dryrun
p4 have $1 | grep -Eo '//.*#[[:digit:]]+' | p4 -x - flush
@bohdon
bohdon / MyProject-GetConfigValue.Build.cs
Last active August 30, 2022 03:57
read a config value in a UE4 ModuleRules
/// <summary>
/// Get a value from a config file for the project of the current target
/// </summary>
/// <returns>true if a value was found for the given section and key</returns>
bool TryGetConfigValue(ConfigHierarchyType ConfigType, string SectionName, string KeyName, out string Value)
{
ConfigHierarchy Config = ConfigCache.ReadHierarchy(ConfigType, DirectoryReference.FromFile(Target.ProjectFile), Target.Platform);
if (Config != null)
{
ConfigHierarchySection Section = Config.FindSection(SectionName);
@bohdon
bohdon / maya_remirror_curve_shapes.py
Created July 3, 2020 18:28
Duplicate all shapes for the selected nodes and move them to the paired mirror node, then flip and mirror color
import pulse
def copyShape(src, dst):
shapes = src.getShapes()
for shape in shapes:
dupe = pm.duplicate(shape, addShape=True)
print(dupe)
pm.parent(dupe, dst, shape=True, relative=True)
pulse.sym.MirrorCurveShapes.flipAllCurveShapes(dst)
mappearance = pulse.sym.MirrorColors()
@bohdon
bohdon / maya_export_sks.py
Last active December 22, 2022 06:46
Export all skeletal meshes from a Maya scene using object sets
import os
import maya.cmds as cmds
import pymel.core as pm
import pulse
def exportSKSets(sourceScenePath, destDir):
"""
Export all SK_* sets from the given scene, unparenting all members
@bohdon
bohdon / maya_select_rotateAxes.py
Created June 10, 2020 19:56
Select rotateAxis on all selected nodes in Maya
import pymel.core as pm
rotateAxes = [s.rotateAxis for s in pm.selected()]
pm.select(rotateAxes)