Skip to content

Instantly share code, notes, and snippets.

View whoiscarlo's full-sized avatar

Carlo Nyte whoiscarlo

View GitHub Profile
@whoiscarlo
whoiscarlo / mayapy.sublime-build
Created January 3, 2018 20:14
Create a Sublime Build
{
"path": "C:/Autodesk/Maya2017-x64/bin/mayapy.exe",
"cmd": ["C:/Autodesk/Maya2017-x64/bin/mayapy.exe", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}
@whoiscarlo
whoiscarlo / timeEditor_test.py
Created November 17, 2017 02:06
Maya Time Editor
## Grab selected
sel_obj = cmds.ls(sl=1)[0]
## Get namespace
namespace = sel_obj.split(':')[0].split('_def')[0]
## Check if main comp exists
if 'main_comp' not in cmds.timeEditorComposition(q=True, allCompositions=True):
## Create composition
from maya.api import OpenMaya
from maya import cmds
def getDistance(x1, y1, z1, x2, y2, z2):
sq1 = (x1-x2)*(x1-x2)
sq2 = (y1-y2)*(y1-y2)
sq3 = (z1-z2)*(z1-z2)
return math.sqrt(sq1 + sq2 + sq3)
@whoiscarlo
whoiscarlo / findNearByPoints.py
Created February 15, 2017 21:06
This script is designed to return ALL nearby vertices inside the selection sphere, whereas you are only looking for whole objects. So you could short circuit this code to continue on to the next object once you have a single matching vertex. (Which should speed up your check by several times for mostly enclosed objects with a large number of verts.
# Origin http://forums.cgsociety.org/archive/index.php?t-904223.html
import maya.OpenMaya as api
import maya.cmds as cmds
def findNearby(point, tolerance):
'''findNearby
point - Either an MPoint, a tuple (x, y, z), or an object name (Uses that objects pivot)
tolerance - The search radius for finding nearby selection
'''
@whoiscarlo
whoiscarlo / threadingwithlocks.py
Created October 7, 2016 22:45
Threading with Lock
import threading
def work(arg, qlock):
'''
Create user file
'''
qlock.acquire()
print arg
qlock.release()
@whoiscarlo
whoiscarlo / Dynamic_PopupMenu.py
Last active July 8, 2016 21:46
Example of Dynamic Popup Menus
'''
Author: Carlo Cherisier
Date: 08.25.15
Script: ZeroOut
import ZeroOut
reload(ZeroOut)
ZeroOut.show_dialog()
'''
import sys
import functools
import sys
import shiboken
from PySide import QtCore, QtGui
import maya.cmds as mc
class TestUI(QtGui.QDialog):
def __init__(self, *args, **kws):
parent = kws.get('parent', None)
@whoiscarlo
whoiscarlo / bootstrap.min.css
Created November 24, 2015 23:15
Bootstrap v3.3.5
/*!
* Bootstrap v3.3.5 (http://getbootstrap.com)
* Copyright 2011-2015 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*//*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}dfn{font-style:italic}h1{margin:.67em 0;font-size:2em}mark{color:#000;background:#ff0}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{height:0;-webkit-box-si
@whoiscarlo
whoiscarlo / mayaGlobalVariables.txt
Created September 18, 2015 19:28
Maya Global Variables
for x in globals(): print x
string
cmd
contextmanager
_LoadPublishedEntityInformationIndividualChar
stereoCameraInitStereo
MayaDependNode
mel
MC
MM
@whoiscarlo
whoiscarlo / mayaCmdPort.py
Created September 16, 2015 23:28
Connecting to Maya's Socket
'''
Command port
http://forums.cgsociety.org/archive/index.php?t-966699.html
Creative Crash
'''
import socket
#HOST = '192.168.1.122' # The remote host
HOST = '127.0.0.1' # the local host
PORT = 54321 # The same port as used by the server
ADDR=(HOST,PORT)