Thanks @Dave Finch for this great example! This is my favorite of all the Minecraft scripts out there already. I’ve update this great tool with a little more Python fancy schmanciness. Made it object oriented and added some functionality with the idea of upgrading the algorithm to generate the maze, make it 3D, and add some funkiness. Stay tuned!
This post includes some additional important support material for what was discussed in [Maya-Config] Phase I. I felt it needed a bit more elaboration than what I had time for. I will continue with Phase II next time.
How do you tame the beast that is your ever growing collection of mel, cpp/python plug-ins, and python scripts?
Curate a library of cross-platform, multi-language extensions!
Teach yourself how to setup a proper library of Maya tools by following the steps outlined here. This is by no means the only way to do it. [edit: This is strictly for learning purposes and not intended for production use, but by all means apply what you learn to your specific production needs at your discretion!] It can get as sophisticated as time permits and as your production demands. To put it simply, this is a great starting place for people wanting to learn some of the basics of how to manipulate your Maya environment. The techniques described are simple, however this isn’t a Maya beginner task so I assume the reader knows a bit about scripting, how to use a shell or command line, and other Maya internals of course. I am willing to break it down in further posts of course. There is a lot of information to go over so this topic will be have to be continued in a series of posts.
Say you have an environment variable named PYROOT with a lis of a few paths where python libs are stored. Use python’s site module to add your lib directories as site directories like this:
import os import site PYTHONPATHS =  if os.environ.has_key('PYROOT'): if os.pathsep in os.environ.get('PYROOT'): for p in str.split(os.environ.get('PYROOT'), os.pathsep): PYTHONPATHS.append(p) else: PYTHONPATHS.append(os.environ.get('PYROOT')) if len(PYTHONPATHS): for j in PYTHONPATHS: site.addsitedir(j)
This quick script works cross-platform using os.pathsep to test for environment variable separators ‘;’ (win) and ‘:’ (linux) and using that to split the PYROOT string variable appending each of the paths to the PYTHONPATHS buffer list. By using the site.addsitedir module, python will treat these directories as normal site-package directories with all the built-in abilities to customize such as sitecustomize module and .pth files. If subdirectories are already organized into packages using __init__.py then they are already ready to be used and imported into Maya right away, or else if the directory has a .py file and no __init__.py just add an empty one.
To add your custom user site-packages directory just append the lines of code or create a new userSetup.py and make sure it is on your PYTHONPATH when you start up, previously explained here, or just put it in any one of the default maya scripts areas.
Find Out How to Turn Custom Text to Realistic Metallic Objects
What do you do when you screw up and delete all your history and input code in Maya script editor usually do to a right-click muscle memory FAIL? First of all, DON’T close Maya! Navigate to your prefs directory, depending on the system you’re using that is in different locations, and then open up the handy little mel file called “commandExecuter”, and that file name may have a hyphen and some numbers behind it depending on how many tabs you have going. Open the corresponding file based on the tab you mistakenly erased in notepad or favorite text editor and then copy the contents back into your script editor.
This won’t get you everything back however, sad, I know, but if you can get back to where you were before the melt-down without too much hassle this way then that’s better than nothing. That’s why I like using external IDE’s for longer coding sessions and the script editor for little things that make my life easier in the particular scene I’m working on.
setuptools – You should have setuptools installed.
pip – If you have setuptools and/or use easy_install switch to pip by using easy_install to download and install pip, you won’t be sorry. Pip is awesome, setuptools sux.
pyWin32 – Use pip to download pyWin32 from the commandline using pip install pyWin32. Copy the installation to your Maya site-packages folder including any .pth, .txt, or .egg-info files. Tip: open .pth files in a text editor of choice and check out where pip’s libs are.
''' based on mel script found here: http://bit.ly/e4qdyH ''' import win32clipboard def getClipboardData(): win32clipboard.OpenClipboard() d = win32clipboard.GetClipboardData( win32clipboard.CF_TEXT ) win32clipboard.CloseClipboard() return d getClipboardData() def putClipboardData(text): win32clipboard.OpenClipboard() win32clipboard.EmptyClipboard() win32clipboard.SetClipboardText( text ) win32clipboard.CloseClipboard() t= 'test text' putClipboardData(t)
This is based on what I found on teacup’s techy art stuff, written a while ago. I though it deserved an update, plus I needed it for something specific. It is a really handy module to have in your repertoire. I posted these in a hurry so you probably need to add in some checks to make sure the datatype you are trying to retrieve is text only or else you’ll get errors.
PyQt and Qt obviously are way more powerful for getting other types of data including pixmap and slew of others. This is simplified for a specific purpose. Maybe soon I will be able to post a Qt version including drag and drop functionality.
Here’s a handy little script you can run in Maya script editor to see a list of CG jobs with corresponding salaries. Obviously, this is kind of a joke because of some of the figures, but it’s still a pretty cool example of using urllib2 module.
VFXWages is a global database of hourly monetary rates of people in the film and television visual effects, animation, motion graphics, and gaming industry. It allows you to see where you rate among the rest of the artists in your experience, occupation and location. Have you ever wondered if you’re earning too little? Pondering what a similar artist in your position is making on the other side of the world? Using our Wages system, you can graphically compare wages and salaries around the world. -via VFXWages.com
Run this from Maya’s script editor, or whatever. Shared by my colleague Mike. It’s kinda neat but sometimes you wonder if this information is real! $100/hr for Anim Sup or Vfx Sup?!
I’m just starting to code seriously in python and it seems like just getting everything to work right in Maya without a lot of fuss is pretty daunting for a beginner with little outside help except for the internet and a couple books.
As my Script Repo develops over time, I don’t want to have to keep worrying about PYTHONPATH having everything in it so I tell it where the root directories are and this script does the rest.
Hope somebody finds this helpful!
import sys from os import walk path = ja_python_paths for p in path: for root, dirs, files in walk(p): if p is not root: sys.path.append(root) #You can add an optional print statement at the end #to see what it's doing... if p is not root: print 'adding', root, 'to sys.path' sys.path.append(root)
Lately, I’ve been working on learning how to develop PyQt UI tools with Maya. Since I work with Maya 2009 daily, I have had to do quite a lot of digging to find out how things were implemented smoothly for it to work with that version. Hopefully, this makes it easier to understand and appreciate it in 2011 and *gasp* :-O 2012, where PyQt is fully integrated! Anyway, if you are in the same predicament, then I should be able to help, send comments and emails my way.