Skip to content

Instantly share code, notes, and snippets.

@SEVEZ
SEVEZ / Copy_pivot.py
Created August 29, 2015 11:18
Copy pivot from second object to first object
'''
Align pivots by Serge Scherbakov.
Usage:
1. Select source object(s)
2. Add to selection target object
3. Run script by 'import copyPivot\n copyPivot.copyPivot()
'''
import maya.cmds as cmds
import maya.mel as mel
@SEVEZ
SEVEZ / crease_hard_edges_conv.py
Created August 29, 2015 11:18
Convert between creased and hard edges
''' [Crease To Normal]
Created on 23.07.2012
edgeCreaser - uses edge Crease info to make it hard edge, or use Hard edge info to make edge crease.
@author: Serge Scherbakov
'''
import maya.cmds as cmds
class edgeCreaser():
@staticmethod
def apply(mode = 'c2n'):
@SEVEZ
SEVEZ / edges_to_curves.py
Created August 29, 2015 11:18
Extract selected edges to curves
from pymel.all import *
sel = ls( selected(), fl=1 )
aCe = []
while len( sel ):
ce = []
for e in sel:
if ce == []: ce.append( e )
else:
@SEVEZ
SEVEZ / vertex_normals_from_sel_faces.py
Created August 29, 2015 11:23
Sets the vertex normals of a face selection, averaging normals shared by multiple selected faces.
# ---------------------------------------------------------------------------------------
# - pompVertNormFaceAvg
#
# - Sets the vertex normals of a face selection,
# averaging normals shared by multiple selected faces.
#
#
# - by Pontus Karlsson 2013 (www.pomperi.com)
# ---------------------------------------------------------------------------------------
@SEVEZ
SEVEZ / select_all_by_type_in_hierarchy.py
Created August 29, 2015 11:23
Select all object by type within hierarchy
cmds.select(cmds.ls(dag=1, ap=1, sl=1, type="joint"))
cmds.select(cmds.ls(dag=1, ap=1, sl=1, type="nurbsCurve"))
cmds.select(cmds.ls(dag=1, ap=1, sl=1, type="constraint"))
@SEVEZ
SEVEZ / check_ref_obj.py
Created August 29, 2015 11:26
Check if object is referenced
selection = cmds.ls(sl = True)
for model in selection:
refcheck = cmds.referenceQuery(model, inr = True)
if (refcheck == 1):
reftodel = cmds.referenceQuery(model, f = True)
cmds.file(reftodel, rr = True)
cmds.file(newfile, r=True)
else:
cmds.delete(model)
cmds.file(newfile, i=True)
import maya.cmds as cmds
def dragAttr( attr_names ):
if not cmds.dragAttrContext('dragAttributeCtx', ex=True):
cmds.dragAttrContext('dragAttributeCtx')
cmds.dragAttrContext( 'dragAttributeCtx', e=True, ct=attr_names )
cmds.setToolTo( 'dragAttributeCtx' )
dragAttr( "Push_Deform2.inflation" )
select `ls -typ "animCurveTL" -typ "animCurveTU" -typ "animCurveTA" -typ "animCurveTT"`; gets just the curves that are animated - i.e. parameters that change over time The 2 letters at the end specify imput and output units input is Time or Unitless output is Linear Unitless Angle or Time - gotta admit, i never knew about the ls -typ "animCurve" catchall - thanks
from pymel.core import *
for s in selected():
so = PyNode( 'tinker_director_anim:' + s )
connectAttr( so.t, s.t, f=1, l=0 )
connectAttr( so.r, s.r, f=1, l=0 )
connectAttr( so.s, s.s, f=1, l=0 )
import maya.cmds as cmds
import maya.mel as mel
import maya.OpenMaya as om
#Add Render Element Extra_Tex
mel.eval("vrayAddRenderElement ExtraTexElement")
#Rename Extra_Tex
cmds.rename("vrayRE_Extra_Tex", "vrayRE_Extra_Tex_UV")