Skip to content

Instantly share code, notes, and snippets.

View loonghao's full-sized avatar
😀
Vibe Coding

Hal loonghao

😀
Vibe Coding
  • Shenzhen
View GitHub Profile
@Kif11
Kif11 / maya-undo-decorator.py
Last active March 2, 2024 09:40 — forked from schworer/undo_dec.py
quick and dirty Maya Python undo decorator
from functools import wraps
from maya import cmds
def undo(func):
""" Puts the wrapped `func` into a single Maya Undo action, then
undoes it when the function enters the finally: block """
@wraps(func)
def _undofunc(*args, **kwargs):
try:
# start an undo chunk
@fredrikaverpil
fredrikaverpil / export.py
Last active July 12, 2019 08:45
Export/import shader assignment with Maya
import maya.cmds as cmds
import json
# Create the dictionary "data" with shadergroup as key
data = {}
shaders = cmds.ls(type='shadingEngine')
for shader in shaders:
data[shader] = []
# Append all shapes to each shadergroup-key
import cask, shutil, json
def save_meta(path, meta):
tmp = path+'.tmp'
shutil.copy2(path, tmp)
a = cask.Archive(tmp)
#exists_prop = a.top.properties
pr = cask.Property()
pr.set_value(json.dumps(meta))
a.top.properties['jmeta'] = pr
@christophercrouzet
christophercrouzet / mayabake.py
Created December 24, 2016 14:03
Quick and dirty prototype of a naive animation bake implementation for Autodesk Maya.
#!/usr/bin/env mayapy
import itertools
import math
import random
import timeit
from maya import cmds, OpenMaya, OpenMayaAnim
REM http://www.microsoft.com/en-us/download/details.aspx?id=40855
REM INSTALL: Windows6.1-KB2819745-x64-MultiPkg
@ECHO off
rem VARIABLES
SET PYTHONINSTALL=C:\python27
SET LOCALFILE=c:\python-2.7.6.amd64.msi
SET PYTHONURL=http://www.python.org/ftp/python/2.7.6/python-2.7.6.amd64.msi
REM My installation python script
SET PWINSTALLER=http://paulwinex.ru/files/pipeline/pwpipeline_install.py
SET PWINSTALLERLOCAL=c:\pwpipeline_install.py
# Create shortcut on desktop for windows
#...................................
def createShortCut(self, data):
executable = join(os.getenv('PIPELINE_LOCATION'), 'start_app.cmd')
if not os.path.exists(executable):
self.trayMessage('Launcher not found')
return
data['launcher'] = executable.replace('/','\\')
data['wd'] = os.getenv('PIPELINE_LOCATION')
ico = icons[data['name']] if data['name'] in icons else icons['default']
import time, hou
# version 1. Static class
class SessionCallback(object):
last_time = time.time()
interval = 10 # sec
@classmethod
@tterb
tterb / README-badges.md
Last active August 19, 2025 18:32
A collection of README badges

Badges

License

MIT License GPLv3 License AGPL License

Version

Version GitHub Release

@liorbenhorin
liorbenhorin / Simple_MayaDockingClass.py
Created December 1, 2017 15:04
Simple way to Docking Qt widgets to Maya 2017+
'''
Template class for docking a Qt widget to maya 2017+.
Author: Lior ben horin
12-1-2017
'''
import weakref
import maya.cmds as cmds
import maya.OpenMayaUI as omui
from pymel.core import *
# original setup
SCENE.defaultRenderGlobals.imageFilePrefix.set('/render_output/frame_<RenderLayer>')
SCENE.defaultRenderGlobals.animation.set(1)
SCENE.defaultRenderGlobals.outFormatControl.set(2)
SCENE.defaultRenderGlobals.putFrameBeforeExt.set(1)
SCENE.defaultRenderGlobals.extensionPadding.set(3)
# get path and add format expression