Skip to content

Instantly share code, notes, and snippets.

View pmolodo's full-sized avatar

Paul Molodowitch pmolodo

  • NVIDIA
  • Los Angeles, CA
View GitHub Profile
@pmolodo
pmolodo / getUVAtPoint.py
Created March 15, 2017 17:13
Example of using MeshFace.getUVAtPoint()
import pymel.core as pm
pm.newFile(f=1)
cube = pm.polyCube()[0]
face = cube.f[4]
pos = pm.dt.Point(.76, .2, -.15)
# the loc isn't necesary, but gives a nice visual indicator of the point we're querying
loc = pm.spaceLocator()
loc.translate.set(pos)
print face.getUVAtPoint(pos, "world", "map1")
@pmolodo
pmolodo / getattribute_and_set_descriptor.py
Created May 16, 2017 21:52
Test __getattribute__ and descriptor __set__
class MyDescriptor(object):
def __init__(self, name, val):
self.name = name
self.theVal = val
def __get__(self, instance, owner):
print "Getting {} from {} (owner: {})".format(self.name, instance, owner)
return self.theVal
@pmolodo
pmolodo / compare_tests.py
Last active May 19, 2017 16:56
utility funcs for gathering information about which tests were run
#execfile('/Volumes/home/paulm/Desktop/compare_tests.py')
# Some utility funcs for printing out the list of tests run - useful for
# ensuring that the same set of tests are run if/when we fully transition to
# pytest
unittest_run_re = re.compile(r'^(?:(?P<normal_testname>test[^ \n]*) \((?P<normal_classname>test[^\n]*)\)|Doctest: (?P<doctest_name>[a-zA-Z0-9_\.]+)) ... ', re.MULTILINE)
def getTestNames_unittest_run(logPath):
'''Parse test names from the output log of a "run_tests" (unittest) invocation'''
names = []
@pmolodo
pmolodo / usdmaya_xforms_export.py
Last active August 31, 2017 19:03
Export and timed import test of usdmaya xforms
# create a bunch of transforms with varying transform attrs set
from random import Random
import itertools
import os
import pprint
import maya.cmds as cmds
ATTRS = {
'translate': (.01, 5),
@pmolodo
pmolodo / test_tanh_crossentropy.py
Last active March 1, 2018 21:11
A cross-entropy function for tanh
'''Tests the performance of a cross-entropy-like cost function, designed for use with tanh activations.
This simple test is attempting to emulate the result of a simple 2D-function:
f(x,y) = tanh(10 * (y - gaussian(x))
My test results show a nearly 2x performance increase after 1000 iterations (judged by mae) vs using MSE as a cost function.
See this post for more info: https://stats.stackexchange.com/questions/221901/can-the-cross-entropy-cost-function-be-used-with-tanh/329921#329921
'''
@pmolodo
pmolodo / connectedToRotateAxis.py
Created August 31, 2018 19:23
Maya 2018 bug with rotateAxis evaluation
########################################################################
# DESCRIPTION:
#
# Produces the custom transform node "ConnectedToRotateAxisNode".
# All it really does is declare an attributeAffects relationship between
# a custom attribute and "rotateAxis", which, in maya 2018, causes a bug
# in evaluation of rotateAxis on the BASE / "normal" transform node!
#
########################################################################
@pmolodo
pmolodo / MAnimCurveChange_bug.py
Created December 21, 2018 01:00
Maya bug report: MAnimCurveChange for an MFnAnimCurve.setTime does not work after undoing/redoing an addKeys
# test AnimCurve.setTime undo/redo - api only
import maya.OpenMaya as om
import maya.OpenMayaAnim as oma
import maya.cmds as cmds
cmds.file(new=1, f=1)
curve = cmds.createNode('animCurveTL')
@pmolodo
pmolodo / UVCubeMap.cs
Last active February 20, 2019 16:22
Example of how to map different parts on one texture onto a cube in Unity - thanks alucardj
// For thread / original UnityScript version, see
// https://answers.unity.com/questions/306959/uv-mapping.html
using UnityEngine;
public class UVCubeMap : MonoBehaviour
{
// using an image that is an 8x8 grid
// each image is 0.125 in width and 0.125 in height of the full image
@pmolodo
pmolodo / testPolyComponentIdChanged.py
Created May 16, 2019 01:02
Removing a addPolyComponentIdChangedCallback can cause a crash (Maya 2019)
#execfile('/Volumes/home/paulm/Desktop/testPolyComponentIdChanged.py')
import maya.cmds as cmds
import maya.api.OpenMaya as om
cmds.file(f=1, new=1)
cubeTrans = cmds.polyCube()[0]
cubeShape = cmds.listRelatives(cubeTrans)[0]
sel = om.MSelectionList()
sel.add(cubeShape)
@pmolodo
pmolodo / merge_al.bash
Last active October 18, 2019 21:22
Scripts for helping with merging issues for Maya-USD and "old" Pixar and Animal Logic Repos
# change to git root dir
cd "$(git rev-parse --show-toplevel)"
# Some commit reference points:
# 19a1e755c258c9ac0d7495fa0add62508ff377a1 - plugins/AL_USDMaya (initial import of pixar from submodule)
# 825ca13dd77af84872a063f146dee1799e8be25c - plugins/AL_USDMaya (some removals)
# 141bab7eba1d380868e822a51f8c8f85e1c0b66f - plugins/AL_USDMaya (identical contents as above)
# e5e10a28d0ba0535e83675399a5d15314fb79ec9 - plugin/al (renamed dir)