Skip to content

Instantly share code, notes, and snippets.

@Roumenov
Roumenov / maya_reference_cleanup.py
Last active October 4, 2020 03:12
procedure to clean up messy references
import pymel.core as pm
import vo_maya.core.vo_export as voe
reload(voe)
pm.ogs(pause=True)
controls = [u'Roxanne_rWristFKC', u'Roxanne_rUpperLegCurveC', u'Roxanne_rUpperLegCurve3C', u'Roxanne_rUpperLegCurve2C', u'Roxanne_rUpperLegCurve1C', u'Roxanne_rUpperArmCurve3C', u'Roxanne_rUpperArmCurve2C', u'Roxanne_rUpperArmCurve1C', u'Roxanne_rLowerLegCurveC', u'Roxanne_rLowerLegCurve3C', u'Roxanne_rLowerLegCurve2C', u'Roxanne_rLowerLegCurve1C', u'Roxanne_rLowerArmCurve3C', u'Roxanne_rLowerArmCurve2C', u'Roxanne_rLowerArmCurve1C', u'Roxanne_rKneeFKC', u'Roxanne_rKneeCurveC', u'Roxanne_rElbowFKC', u'Roxanne_rBallFKC', u'Roxanne_rAnkleFKC', u'Roxanne_lWristIKC', u'Roxanne_lUpperLegCurveC', u'Roxanne_lUpperLegCurve3C', u'Roxanne_lUpperLegCurve2C', u'Roxanne_lUpperLegCurve1C', u'Roxanne_lUpperArmCurve3C', u'Roxanne_lUpperArmCurve2C', u'Roxanne_lUpperArmCurve1C', u'Roxanne_lLowerLegCurveC', u'Roxanne_lLowerLegCurve3C', u'Roxanne_lLowerLegCurve2C', u'Roxanne_lLowerLegCurve1C', u'Roxanne_lLowerArmCurve3C', u'Roxanne_lLow
@Roumenov
Roumenov / eye_attr_setup.py
Created September 29, 2020 04:40
messing around with creating attributes to drive shader params
eye_ramp = pm.ls('geo:R_eye_ramp')[0]
eye_joints = pm.ls(sl=1)
eye_control = pm.ls(sl=1)[0]
#checked items fill list of attrs
#'blink'
eye_parts = ('pupil', 'iris') #'offset'
eye_attrs = ('radius', 'shape', 'angle', 'stretch')
#pm.addAttr(longName = 'iris', type = 'float')
@Roumenov
Roumenov / correct_anim_offset.py
Created March 5, 2020 09:28
simple proc to offset keys
import pymel.core as pm
targets = ['Corsac_R_brow_CTL_04', 'Corsac_R_brow_CTL_03', 'Corsac_R_brow_CTL_02', 'Corsac_R_brow_CTL_01']
controls = pm.ls(targets, recursive = True)
for item in controls:
pm.selectKey(item, attribute = 'rotateZ', replace = True)
pm.keyframe(edit = True, relative = True, valueChange = -180.0)
@Roumenov
Roumenov / maya_add_menu.py
Last active March 5, 2020 09:12
simple proc for making a custom menu in maya
import maya.cmds as mc
main_window = pm.language.melGlobals['gMainWindow']
menus = mc.window(main_window, query=True, menuArray=True)
if menu_name in menus:
mc.deleteUI(menu_name, menu=True)
mc.menu(menu_name,
parent=main_window,
label="Foo",
tearOff=True)
@Roumenov
Roumenov / file_renamer.py
Last active March 1, 2020 13:48
primitive procedure to rename a bunch of files that broke with naming convention
import shutil, os
current_directory = os.getcwd()
filename = 'output.txt'
for file in os.listdir(current_directory):
active = file.replace('_idle', '_act')
print(active)
if '_idle' in file and not os.path.isfile(active):
output = file.replace('_idle','_act')
@Roumenov
Roumenov / constraints.py
Created February 5, 2020 10:55
messing around with storing constraint values to rebuild later
target = pm.ls(sl=1)[0]
constraint = set(pm.listConnections(source = True, type = 'constraint')).pop()
print(constraint.Target)
sources = list(set(constraint.listConnections(source = True, type = 'transform')))
sources.remove(target)
source_weight = {}
for item in sources:
@Roumenov
Roumenov / anim_curve_anchor.py
Created November 18, 2019 06:27
blocking out thoughts for a useful animation curve utility
start_time = 0
end_time = 10
keyed_channels = get_keyed_channels()
for curve in keyed_channels:
#what is the best method to select the target keys?
#select keys in range(start_time,end_time)
@Roumenov
Roumenov / primitiveWindow.py
Created November 10, 2019 16:33
playing with how maya builds windows, layouts, and controls
import pymel.core as pm
def primitiveWindow(name = 'primitiveWindow'):
if pm.window(name, query=True, exists=True):
pm.deleteUI(name)
pm.window(name)
pm.showWindow(name)
@Roumenov
Roumenov / blendshape.py
Last active May 19, 2020 03:23
add blendshape proc because the maya ui for this is obtuse and i always fuck it up like an idiot
import pymel.core as pm
def get_blendShape(target):
"""Get blendshape of target."""
if (pm.nodeType(target.getShape()) in ["mesh", "nurbsSurface", "nurbsCurve"]):
blendShape = pm.listHistory(target, type="blendShape")[0]
return blendShape
def add_blendShape(new_shape, blend_mesh):
"""
@Roumenov
Roumenov / vertex_selection.py
Last active September 29, 2019 05:14
example of weird phenomenon when selecting verts of referenced mesh
import pymel.core as pm
target_mesh = pm.ls(sl=1)[0]
print target_mesh
pm.select("mesh:simple_plane.vtx[*]")
pm.select("mesh:Xidriel_head_mesh.vtx[*]")
target_mesh.vtx[0].select()
target_mesh.vtx[:].select()