Skip to content

Instantly share code, notes, and snippets.

@robomojo
robomojo / scriptJobRemover.py
Created October 4, 2013 04:36
remove annoying scriptjobs
import pymel.core as pm
# look through scriptjobs, which are strings. Find the annoying one and kill it.
for each in pm.scriptJob(listJobs=True):
if 'syncChannelBoxFcurveEd' in each:
index = int(each.split(':')[0])
pm.scriptJob(kill=index)
import re
for each in nodes:
result = re.search('\Acollision_wall', each.name().split('|')[-1]) is not None
if result: print each.name()
@robomojo
robomojo / mayaProgressBar.py
Last active June 21, 2019 20:51
maya progress bar
import maya.cmds as mc
import pymel.core as pm
class ProgressBar:
def __init__ (self,title,steps):
#self.step = 0
self.title=title
self.steps = steps
self.progressControls = []
self.progressbar = self.makeProgressBarWindow()
@robomojo
robomojo / duptest.py
Created September 22, 2013 14:15
quick test for duplicating, then merging without creating loads of extra transforms
# assumes:
# from pymel.core import *
print 'starting test'
system.newFile(force=True)
#print len(ls())
def makecubes (count):
cubes = []
@robomojo
robomojo / maya.py
Created September 22, 2013 14:13
ipython and pymel loader to call from mayapy
print 'maya.py is running!'
print 'importing pymel.core'
from pymel.core import *
import sys
sys.path.append('c:\\py')
def get (file):
@robomojo
robomojo / makeNames.py
Created September 20, 2013 01:38
converts 40 to '00040'
def getNumberStringWithPreZeros(i,m):
name = str(i)
for i in range(0,max(m-len(name),0)): name = '0'+name
return name
print getNumberStringWithPreZeros(40,3)
@robomojo
robomojo / pointOnCurve.py
Created September 20, 2013 00:52
makes points on a nurbsCurve
def makePointsOnCurve (c,x,g):
select(clear=True)
g = group (name=g)
count = 300
for i in range(0,count):
p = spaceLocator()
percentage = ( float(i)/count*100 ) * 0.01
pos = pointOnCurve (c, parameter=percentage, turnOnPercentage=True)
p.setTranslation(pos)
rename(selected()[0],'node_'+str(i))
@robomojo
robomojo / getParentHierarchy.py
Created September 19, 2013 23:56
gets a list of parent objects
# recurse through parents, building a list as we go
def getAllParents (parents):
parent = listRelatives(parents[len(parents)-1],allParents=True)
if len(parent)>0 :
parents.append(parent)
getAllParents(parents)
return parents
ap = getAllParents([selected()[0]])
@robomojo
robomojo / errors.py
Created September 6, 2013 11:46
maya learning stuff
# ERRORS AND WARNINGS
# maya cmds
import maya.cmds as cmds
cmds.warning('this is an warning')
cmds.error('this is an error')
# openmaya mglobal
import maya.OpenMaya as om
om.MGlobal.displayError('this is a display error - code not interrupted')
@robomojo
robomojo / mayascripts.py
Created September 6, 2013 04:26
For maya, load in a separate repository. expects to import an 'init' module and a 'scripts.path' file to give the directory of the maya scripts repository.
import sys,os,maya
print ('calling maya scripts...')
(filepath,filename) = os.path.split(maya.cmds.file(q=True,l=True)[0])
path = open(filepath+'//scripts.path').readline()
sys.path.append(path)
import init
init.path=path