Skip to content

Instantly share code, notes, and snippets.

@Roumenov
Roumenov / mesh_density_calc.py
Last active August 10, 2019 08:59
need to sort meshes relative to each other by various parameters.
import pymel.core as pm
import maya.mel as mel
def mesh_density_calc(mesh, operation = 'density'):
#TODO: add line ot save existing selection and reselect at the end
pm.select(mesh)
if operation == 'volume':
return mel.eval('computePolysetVolume ')
elif operation == 'polycount':
import pymel.core as pm
import maya.cmds as cmds
#Version: 1.1.2
#declaring initial variables
#global playStartTime
#global playEndTime
def ab_getFile():
@Roumenov
Roumenov / sylv_batch_export.py
Created August 31, 2019 01:25
example commands for batch exporting Sylvia
import pymel.core as pm
import vo_sceneTools as st
reload(st)
#this will select sylvia's root control regardless of the namespace
#when replacing for another character, make sure to keep the *: characters if there's a namespace
pm.select('*:sylv_root_CTL')
st.export_character('auto')
@Roumenov
Roumenov / meta_tag.py
Last active February 25, 2020 09:19
metaRig test setup.. also messing with what kind of objects I can pass to red9 for instancing r9MetaClass
"""
metaRig test setup
also messing with what kind of objects I can pass to red9 for instancing r9MetaClass
skinned_mesh
"""
import Red9.core.Red9_Meta as r9Meta
import maya.cmds as cmds
@Roumenov
Roumenov / shelf_setup.py
Last active September 13, 2019 20:15
loading and deleting shelves with pathSetup commands.
import vo_maya
reload(vo_maya)
for item in os.listdir(vo_maya.VO_SHELF_PATH):
#shelf names looke like 'shelf_vo_polyTools.mel'
shelf_name = 'vo_' + item.split('_')[2].replace('.mel','')
print(shelf_name)
ps.delete_shelf(shelf_name)
shelf_path = os.path.normpath(os.path.join(vo_maya.VO_SHELF_PATH,item)).replace('\\', '/')
ps.load_shelf(shelf_path)
@Roumenov
Roumenov / move_weight.py
Last active September 28, 2019 16:49
move skinCluster weight values from one influence to another
import pymel.core as pm
#select the mesh, the source influence, and the target influence you want to move weights to
target_mesh, source_influence, target_influence = pm.ls(sl=1)[0:3]# unpack selection
target_skinCluster = target_mesh.listHistory(type='skinCluster')[0] # pm.mel.findRelatedSkinCluster(target_mesh) should also work
#verts = target_mesh.select("pSphere1.vtx[*]")
target_skinCluster.addInfluence(target_influence, weight = 0.0)
pm.select(target_mesh.vtx[:])
pm.skinPercent(target_skinCluster, tmw=[source_influence, target_influence]) # the data from the first will be written to the second
@Roumenov
Roumenov / slave_skeleton.py
Last active September 28, 2019 22:57
bunch of messy procs for moving skinweights to bind joints and then contraining them to the prior
#bunch of messy procs for moving skinweights to bind joints and then contraining them to the prior
import pymel.core as pm
target_mesh = pm.ls(sl=1)[0]# unpack selection
target_skinCluster = target_mesh.listHistory(type='skinCluster')[0] # pm.mel.findRelatedSkinCluster(target_mesh) should also work
source_influence, target_influence = pm.ls(sl=1)[0:2]# unpack selection
target_skinCluster.addInfluence(target_influence, weight = 0.0)
@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()
@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 / 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)