Skip to content

Instantly share code, notes, and snippets.

View csaez's full-sized avatar

Cesar Saez csaez

View GitHub Profile
@csaez
csaez / fonts.conf
Created January 2, 2017 04:11
Fix green border around fonts in GIMP (/etc/gimp/2.0/fonts.conf)
<fontconfig>
<match target="font">
<edit name="rgba" mode="assign">
<const>none</const>
</edit>
</match>
</fontconfig>
import random
import pprint
class Transform:
def __init__(self):
self._translate = [0.0, 0.0, 0.0]
self._rotate = [0.0, 0.0, 0.0]
self._scale = [1.0, 1.0, 1.0]
@csaez
csaez / hideSignInButton.py
Last active February 3, 2020 11:13
Hide Maya 2017 "Sign In" button at the top of the screen.
from PySide2 import QtWidgets
def mainWindow(widget):
mw = widget.parent()
if not mw:
return widget
return mainWindow(mw)
if __name__ == "__main__":
mw = mainWindow(QtWidgets.QApplication.activeWindow())
@csaez
csaez / QDictBox.py
Created February 16, 2016 12:58
Dynamic QDialog creating widgets from a python dictionary
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}
@csaez
csaez / pyside_dynamic.py
Created February 9, 2016 13:49 — forked from cpbotha/pyside_dynamic.py
pyside_dynamic.py with minor improvements - also see http://stackoverflow.com/a/14894550/532513
#!/usr/bin/python2
# -*- coding: utf-8 -*-
# Copyright (c) 2011 Sebastian Wiesner <lunaryorn@gmail.com>
# Modifications by Charl Botha <cpbotha@vxlabs.com>
# * 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
@csaez
csaez / guiThingy.py
Last active August 2, 2019 13:37
Maya: A simple qt gui that can be ran within Maya or as standalone (notice the shebang)
#!/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)
@csaez
csaez / transform_clipboard.py
Created December 14, 2015 12:11
MAYA: save/load transforms
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:
@csaez
csaez / toggleVisibilityByType.py
Last active December 8, 2015 10:15
MAYA: Toggle viewport visibility by type
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")
@csaez
csaez / shading_state.py
Last active December 14, 2015 12:16
MAYA: quick and dirty way to save/load shading states between render layers
import maya.cmds as mc
if not hasattr(mc, "CLIPBOARD"):
mc.CLIPBOARD = dict()
def get_shading(node):
rval = dict()
type_ = cmds.nodeType(node)
@csaez
csaez / constants.py
Created September 27, 2015 07:14
Stupid workaround to set variables programmaticaly in the main namespace while working with jedi/rope autocomplete.
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():