Skip to content

Instantly share code, notes, and snippets.

View patwooky's full-sized avatar

Patrick Woo patwooky

View GitHub Profile
@patwooky
patwooky / py_findEmptyGroups_v001_01.py
Last active August 2, 2023 05:50
Select all transform nodes that have no shape nodes under them
# Find Empty Groups V001_01
# Select all transform nodes that have no shape nodes under them
if not 'pm' in dir():
import pymel.core as pm
print ('imported pymel')
else:
print('pymel exists')
@patwooky
patwooky / zeroSmallValues_v001_02.py
Last active March 9, 2023 07:45
This script compares values of each attribute with a "central value" if the values deviate within a certain threshold from the central value, set the value to the central value.
'''
written by Patrick Woo (patrickwoo@yahoo.com)
20230309
version 001_02
change log
v001_02
- now the tool reports number of attributes and number of objects changed
This script compares values of each attribute with a "central value"
@patwooky
patwooky / 20221006_splitListNChunks.py
Last active October 6, 2022 03:34
A short snippet that allows us to split a continuous list into sub-lists of N numbers
# a short snippet that allows us to split a continuous list into sub-lists of N numbers
def splitList(inList, subListSize):
'''
splits a continuous list into sub-lists of N numbers
inList - <list> a list of elements to split
subListSize - <int> the chunk size to split inList into
returns a list of sublists the size of subListSize
'''
a = list(range(12))
@patwooky
patwooky / make_mp4.bat
Last active September 26, 2019 19:43
This script creates an mp4 movie from the source movie file. The input movie can be of any format readable by ffmpeg. if DJV viewer is present, it will launch the viewer after the mp4 is created
@echo off
REM ------------------------------------------------------------
REM Written by Patrick Woo patrickwoo@yahoo.com
REM date: 20190927
REM version v002_01
REM This script creates an mp4 movie from the source movie file
REM The input movie can be of any format readable by ffmpeg
REM if DJV viewer is present, it will launch the viewer after the mp4 is created
@patwooky
patwooky / 20190625_mayaDisplayLayerToggle.py
Last active June 27, 2019 04:09
This Maya script creates a window with a huge button to toggle visibility of a selected Display Layer.
'''
Display Layer Toggle
Written by Patrick Woo patrickwoo@yahoo.com
20190625
Descrption:
This Maya script creates a window with a huge button to toggle visibility of a selected Display Layer.
An additional text field is present for the user to select the display layer to affect.
Selection of the existing display layer is done by clicking on the text field and selecting
from a popup menu, an existing display layer.
@patwooky
patwooky / 20190608_mayaSearchStrInHierarchy.py
Last active June 8, 2019 08:00
In Maya, search for object transform nodes that has a name containing the search string inside the hierarchy of the currently selected objects
from pymel.core import *
'''
In Maya, search for object transform nodes that has a name containing the search string inside the hierarchy of the currently selected objects
'''
srchStr = 'BigBranch'
select([x for x in listRelatives(ls(sl=True, type='transform'), ad=True, type='transform') if srchStr in x.name()])
# -- here's a single line version of the above, if needed for whatever
# srchStr='_geo';from pymel.core import *;select([x for x in listRelatives(ls(sl=True, type='transform'), ad=True, type='transform') if srchStr in x.name()])
@patwooky
patwooky / 20190608_dupObjs_v001_01.py
Created June 7, 2019 17:36
This Maya script takes a source object and creates duplicates or instances, and for each target, move the duplicated/instanced source to match position, orientation and scale.
from pymel.core import *
'''
written by Patrick Woo (patrickwoo@yahoo.com)
This Maya script takes a source object and creates duplicates or instances, and for each target,
move the duplicated/instanced source to match position, orientation and scale.
'''
def dupObjs(inList, dupMode):
'''
@patwooky
patwooky / 20190516_bake_mm_cam_v001_01.py
Created May 17, 2019 03:10
Bakes a Maya camera's Translate rotate and focal length out, set all keys to spline tangents, and set pre/post infinity of curves to linear
from pymel.core import *
from pprint import pprint as pp
'''
BakeMmCam
version 001_01
written by Patrick Woo (patrickwoo@yahoo.com)
This script
- bakes a Maya camera's Translate rotate and focal length out,
@patwooky
patwooky / 20190411_maya_nested_list_comprehensions_learn.py
Created April 11, 2019 09:13
An example of a working nested list comprehension
from pymel.core import *
# an example of a working nested list comprehension
# this example is 2 levels deep
'''
-- Explanation --
for each selected object, list all the connections of type 'animCurve'
for each of the connected animCurve nodes, shortlist those with 'rotateX' in their names
@patwooky
patwooky / 20190306_arnold_aiLightFiltersUtil_v02.py
Last active March 7, 2019 08:07
Maya Arnold light filters apply to many (Arnold compatible) lights with Maya UI
'''
connectAiLightFilters
Written by: Patrick Woo (patrickwoo@yahoo.com)
Version: v02
Date: 20190307
--- Description ---
This tool connects Arnold light filters (decay, gobo, blocker, barn door) to Arnold lights
This is especially useful when we want to duplicate many lights, which are all connected to the same