Skip to content

Instantly share code, notes, and snippets.

@robomojo
robomojo / ptvsd_data.json
Last active August 12, 2019 14:56
Using VSCode for python development can require specific versions of PTVSD. Dropping this module into the project and using the environment variable can make things easier.
{
"path" : "C:\\downloaded\\ptvsd-4.2.9\\src",
"attach" : true,
"host" : "localhost",
"port" : 5678,
"wait" : true
}
import pymel.core as pm
def GetDistanceBetweenVectors (objA, objB):
'''
returns a float.
Expects the name of two objects.
Uses Pymel to get translation - probably a better way to do this.
'''
Ax, Ay, Az = pm.PyNode(objA).getTranslation(space="world")
Bx, By, Bz = pm.PyNode(objB).getTranslation(space="world")
@robomojo
robomojo / pyfmodex_sample.py
Created December 2, 2013 07:13
example using pyfmodex
import pyfmodex
system = pyfmodex.System()
system.init()
sound = system.create_sound('audio.wav')
channel = sound.play(paused=True)
channel.frequency=9000
channel.paused=False
channel.frequency=4000
@robomojo
robomojo / __init__.py
Created October 12, 2013 00:33
an hopefully extendable framework for getting groups of names from a big list of names
import finder
objects = (
'door',
'mirror',
'bonnet',
'lense',
'focallength',
'lenscap',
'milkcrate',
@robomojo
robomojo / findskin.py
Created October 8, 2013 05:09
find maya skincluster
def findSkinClusters ():
skins = []
shapes = pm.listRelatives(shapes=True, noIntermediate=True)
for shape in shapes:
skinClusters = pm.ls(type=pm.nodetypes.SkinCluster)
for skin in skinClusters:
mesh = pm.skinCluster(skin, q=True, g=True)
if mesh[0] == shape:
relatedSkinCluster = sc
skins.append(skin)
@robomojo
robomojo / clearSkin.py
Created October 8, 2013 02:03
clear skin weighting
import pymel.core as pm
skin = pm.ls(type=pm.nodetypes.SkinCluster)[0]
# assign all weight to first influence
pm.skinPercent(skin, transformValue = (skin.getInfluence()[0].name(),1))
# clear skin
pm.skinPercent(skin, normalize=False, zeroRemainingInfluences=True)
@robomojo
robomojo / mayashelves.py
Created October 7, 2013 22:22
some code to access maya shelves using pymel
import pymel.core as pm
import maya.mel as mel
topLevelShelf = mel.eval('string $m = $gShelfTopLevel')
shelves = pm.shelfTabLayout(topLevelShelf, query=True, tabLabelIndex=True)
for index, shelf in enumerate(shelves):
pm.optionVar(stringValue=('shelfName%d' % (index+1), str(shelf)))
# print shelf
@robomojo
robomojo / playblast.py
Created October 7, 2013 05:49
maya quickrender
import os
import pymel.core as pm
cameras = pm.ls(type=pm.nodetypes.Camera)
for each in cameras:
val = True if 'preview' in each.name() else False
if val: playblasting = True
pm.setAttr(each.renderable,val)
each.setFilmFit('verticalFilmFit')
import pymel.core as pm
import re
from pprint import pprint
class NodeGetter:
def __init__(self,args):
'''
Unpacks args to: nodename, searchmethod.
'''
(
import pymel.core as pm
def quickSelect(search):
nodes = pm.ls(type=pm.nodetypes.Transform)
pm.select(clear=True)
for each in nodes:
for subeach in search:
if subeach == each.name().replace(':','|').split('|')[-1]:
pm.select(each,add=True)
quickSelect(['somename'])