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 | |
from PySide import QtGui, QtCore | |
from shiboken import wrapInstance | |
from maya import OpenMayaUI | |
class HardReload(QtGui.QDialog): | |
def __init__(self, *args, **kwds): | |
super(HardReload, self).__init__(*args, **kwds) |
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 maya import cmds | |
def is_camera(node): | |
cond = ( | |
"camera" in [cmds.nodeType(x) for x in (cmds.listRelatives(node, s=True, f=True) or [])], | |
cmds.nodeType(node) == "camera", | |
) | |
return any(cond) | |
cameras = [c for c in cmds.ls(sl=True, l=True) if is_camera(c)] |
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 _getConstants(): | |
return {"FOO": "foo", "BAR": "bar", "BAZ": "baz"} | |
def _updateConstants(): | |
import os | |
# assemble code | |
code = "# This code is automatically generated by constants.py\n\n" | |
for k, v in _getConstants().iteritems(): |
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 maya.cmds as mc | |
if not hasattr(mc, "CLIPBOARD"): | |
mc.CLIPBOARD = dict() | |
def get_shading(node): | |
rval = dict() | |
type_ = cmds.nodeType(node) |
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 maya.cmds as mc | |
def toggleVisibilityByType(type_): | |
options = {type_: True} | |
state = mc.modelEditor("modelPanel4", q=True, **options) | |
options[type_] = not state | |
mc.modelEditor("modelPanel4", e=True, **options) | |
toggleCurvesVisibility = lambda: toggleVisibilityByType("nurbsCurves") | |
toggleJointsVisibility = lambda: toggleVisibilityByType("joints") |
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 maya.cmds as mc | |
if not hasattr(mc, "CLIPBOARD"): | |
mc.CLIPBOARD = dict() | |
def saveTransforms(nodes=None): | |
nodes = nodes or mc.ls(sl=True, l=True) | |
for longName in nodes: |
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
#!/usr/autodesk/maya/bin/mayapy | |
import sys | |
for each in ("PySide", "PySide2"): | |
try: | |
if each == "PySide2": | |
_temp = __import__(each, globals(), locals(), ['QtWidgets'], -1) | |
QtWidgets = _temp.QtWidgets | |
else: | |
_temp = __import__(each, globals(), locals(), ('QtGui'), -1) |
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
#!/usr/bin/python2 | |
# -*- coding: utf-8 -*- | |
# Copyright (c) 2011 Sebastian Wiesner <[email protected]> | |
# Modifications by Charl Botha <[email protected]> | |
# * customWidgets support (registerCustomWidget() causes segfault in | |
# pyside 1.1.2 on Ubuntu 12.04 x86_64) | |
# * workingDirectory support in loadUi | |
# found this here: | |
# https://github.com/lunaryorn/snippets/blob/master/qt4/designer/pyside_dynamic.py |
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 PySide import QtGui | |
class QDictBox(QtGui.QDialog): | |
WIDGETS = {str: QtGui.QLineEdit, | |
unicode: QtGui.QLineEdit, | |
int: QtGui.QSpinBox, | |
float: QtGui.QDoubleSpinBox, | |
list: QtGui.QComboBox, | |
bool: QtGui.QCheckBox} |