This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
def enum(*sequential, **named): | |
enums = dict(zip(sequential, range(len(sequential))), **named) | |
return type('Enum', (), enums) | |
EnumMode=enum('Toggle','ForceUnique','ForceInstance') | |
mode=EnumMode.Toggle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
for each in bpy.context.selected_objects: | |
newName = each.data.name | |
hasOriginal = each.data.name.find('.')>0 | |
if hasOriginal: | |
newName = each.data.name.split('.')[0] | |
each.name = newName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy,sys | |
print ('calling scripts...') | |
filepath=bpy.path.abspath('//') | |
path = open(filepath+'scripts.path').readline() | |
sys.path.append(path) | |
import init | |
init.path=path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os | |
(filepath,filename) = os.path.split(maya.cmds.file(q=True,l=True)[0]) | |
if 'scripts.py' in os.listdir(filepath): | |
if filepath not in sys.path: sys.path.append(filepath) | |
import scripts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy, sys | |
sys.path.append(bpy.path.abspath('//')) | |
import scripts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |