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 | |
print 'moduleTestSysExit running' | |
print __name__ | |
print 'i am quitting' | |
# quitting in a module to see if it quit the main running function | |
# (it actually does quit the main function) | |
sys.exit('i quit') |
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
''' | |
--- | |
makeBoundingBoxGeo | |
version: v01_01 | |
date: 2016-10-21 | |
Patrick Woo | |
[email protected] | |
--- | |
creates a box from selection's bounding box | |
''' |
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
from pymel.core import | |
def getAttrCategories(obj=None): | |
''' | |
Maya attributes can have categories assigned to them | |
we can implement our own categories in attributes at creation time | |
this function returns a list of categories present in a Maya object's attributes | |
''' | |
if not obj: | |
print 'getAttrCategories: no objects passed in. aborted' | |
return |
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 uniformScaleLock(sel=ls(sl=True)): | |
''' | |
connects scaleX to scaleY and scaleZ, and locks scaleY and scaleZ | |
run it again and it will unlock scaleY, scaleZ, and disconnect both the attrs | |
''' | |
if not sel: | |
print 'nothing selected. quitting' | |
return | |
if type(sel) == type(list()): | |
sel = sel[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
''' | |
--- | |
Duplicates to Instances | |
version: v01_04 | |
date: 20161031 | |
Written by: Patrick Woo | |
[email protected] | |
--- | |
Description: |
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
from pymel.core import * | |
def mayaArnoldSubdivSet(): | |
''' | |
changes the subdivision type of a mesh shape for Arnold rendering in Maya. | |
Without subdivisions enabled, the mesh will not tessellate further for displacement. | |
The following takes each selected object and turns the mesh subdiv type into catclark type. | |
''' | |
counter = 0 | |
for x in listRelatives(ls(sl=True), ad=True, type='shape'): | |
x.aiSubdivType.set(1) # set shape node arnold subdivType to 'catclark' |
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 os | |
myPath = r'W:\FROM_TVC' | |
# list all objects in the directory | |
[os.path.join(myPath, x) for x in os.listdir(myPath)][:5] | |
''' | |
# Result: ['W:\\FROM_TVC\\.DS_Store', | |
'W:\\FROM_TVC\\._.DS_Store', | |
'W:\\FROM_TVC\\._9430_Dynamo', | |
'W:\\FROM_TVC\\._xxxx_Dig_SkyPlus', | |
'W:\\FROM_TVC\\._9451_Duracell'] # |
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 timeit | |
from functools import partial | |
def myEquals(numItems): | |
xList = [str(x) for x in xrange(numItems)] | |
# print xList | |
xCompList = [] | |
for n in xrange(len(xList)): | |
for o in xrange(n): | |
for p in xrange(len(xList)): |
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
myList = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'] | |
for idx, y in enumerate(myList): | |
print idx, y, myList[idx+1] if idx < len(myList)-1 else y | |
# output | |
''' | |
0 a b | |
1 b c | |
2 c d | |
3 d e |
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
from pymel.core import * | |
findTextureStr = 'concreteBrightMask.png' # the name of an image to search file names from | |
candidateNodesList = [x for x in ls(type='file') if findTextureStr in x.fileTextureName.get()] | |
print 'texture file found in these file textures:\n{}'.format(candidateNodesList) | |
select(candidateNodesList, replace=True) |