Skip to content

Instantly share code, notes, and snippets.

View tbttfox's full-sized avatar

Tyler Fox tbttfox

View GitHub Profile
from __future__ import print_function
import os
import shutil
import time
from maya import cmds
RELEASE_TYPES = ["Debug", "RelWithDebInfo", "Release"]
def reloadPlugin(
from maya import cmds
from itertools import groupby
def mayaSelRange(vals):
"""Convert maya cmds.ls() component selection list into indices
Arguments:
vals (list): A list of components like what you get out of cmds.ls(sl=True)
@tbttfox
tbttfox / Maya2020.natvis
Created August 17, 2022 06:09
A file that enables sane viewing of Maya 2020 array types in the Visual Studio debugger
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="Autodesk::Maya::OpenMaya20200000::MAttributePatternArray">
<DisplayString>{{ length = {((size_t*)(arr))[4]} }}</DisplayString>
<Expand>
<Item Name="[Length]">((size_t*)(arr))[4]</Item>
<ArrayItems>
<Size>((size_t*)(arr))[4]</Size>
<ValuePointer>debugPeekValue</ValuePointer>
</ArrayItems>
def combineFaces(faces, edgesToDelete):
""" This is where the edge deletion actually happens
Turn a group of connected faces into a new polygon
"""
# TODO
pass
def deleteEdges(counts, connects, edgesToDelete):
@tbttfox
tbttfox / imathnumpy.py
Created April 2, 2019 22:32
address based complete imathnumpy
import numpy as np
import imath
from ctypes import (
c_bool, c_byte, c_ubyte, c_short, c_ushort,
c_int, c_uint, c_float, c_double
)
# imathArrayType: (numpyDType, ctype, dim, dataShape)
_CONVERT_DICT = {
# vertices
@tbttfox
tbttfox / mayaConfigure2018.bat
Created March 19, 2019 22:23
Batch file I use to build a cmake project requiring maya 2018
setlocal
SET BUILD=mayabuild18
SET MAYA_VERSION=2018
SET COMPILER=Visual Studio 15 2017 Win64
SET PFX=%~dp0
cd %PFX%
rmdir %BUILD% /s /q
mkdir %BUILD%
@tbttfox
tbttfox / mayaToNumpy.py
Last active September 15, 2023 09:00
Blazing fast maya api types to Numpy conversion
from maya import OpenMaya as om
import numpy as np
from ctypes import c_float, c_double, c_int, c_uint
_CONVERT_DICT = {
om.MPointArray: (float, 4, c_double, om.MScriptUtil.asDouble4Ptr),
om.MFloatPointArray: (float, 4, c_float , om.MScriptUtil.asFloat4Ptr),
om.MVectorArray: (float, 3, c_double, om.MScriptUtil.asDouble3Ptr),
om.MFloatVectorArray: (float, 3, c_float , om.MScriptUtil.asFloat3Ptr),
om.MDoubleArray: (float, 1, c_double, om.MScriptUtil.asDoublePtr),
@tbttfox
tbttfox / fuzzyfinder.py
Created December 2, 2016 20:27
Python no-import fuzzy finder
def fuzzyfinder(pattern, collection):
results = []
for item in collection:
key = []
# Start the find at the beginning of the string
index = -1
for x in pattern:
# Find the next letter in the pattern after the prevous match