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 StringIO import StringIO | |
class SilencedError ( Exception ): | |
pass | |
class Silencer( object ): | |
''' | |
suppress stdout and stderr |
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
''' | |
add all the zip files in the current directory to the python path. | |
Modules will be loaded in alphabetical order. Once all zips are added to the path, | |
each zip file which contains module with the same name (CASE SENSITIVE) itself will | |
automatically be imported using "import <zipnname>". All side-effects will happen | |
inside a maya executeDeferred call (so the maya environment should be fully loaded). | |
It's a good idea to be very sparing in the use of auto-loading modules! |
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
''' | |
ModuleManager.py | |
Defines ModuleManager class for enabling/disable Maya modules, and ModuleManagerDialog - a GUI for same. | |
Copyright (c) 2014 Steve Theodore. All rights reserved. | |
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | |
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. |
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
''' | |
events.py | |
Defines a simple event handler system similar to that used in C#. | |
''' | |
import weakref | |
import inspect | |
import maya.utils |
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
// requires photoshop CS5+ | |
// create a new socket | |
conn = new Socket(); | |
var keep_serving = true; | |
// sample functions. In a real application you'd have handler functions that could accept more complex inputs | |
var alrt = alert; // pop a dialog | |
var newLayer = function () { return app.activeDocument.artLayers.add(); }; // make a layer | |
var stop = function () { keep_serving = false; }; // stop the server |
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 socket | |
HOST = '127.0.0.1' | |
PORT = 8789 | |
def send_photoshop(msg): | |
''' | |
Expects a photoshop instance running a tcp server on HOST:PORT | |
''' | |
conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
conn.connect((HOST,PORT)) |
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
class CtlProperty (object): | |
''' | |
Property descriptor. When applied to a Control-derived class, invokes the correct Maya command under the hood to get or set values | |
''' | |
def __init__(self, flag, cmd): | |
assert callable(cmd), "cmd flag must be a maya command for editing gui objects" | |
self.Flag = flag | |
self.Command = cmd |
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 constructor(self, name): | |
self.Name = name | |
example = type('Example', (), {'__init__':constructor } ) | |
Test = example("Hello world") | |
# <__main__.Example object at 0x00000000022D6198> | |
Test.Name | |
# Hello world |
OlderNewer