Friday, December 16, 2011

Interacting with Maya: A Flow Chart


So, learning how to program is important for a technical animator, but I thought it'd be important to go over how it all works inside of Maya. There are four different programming interfaces inside of Maya (three of those interfaces are programming languages the other one is the Python API). The three languages are MEL, Python, and C++.

MEL: Maya Embedded Language. It's only used inside of Maya and defines/creates all of the Maya GUI options. You can also use MEL to script basic repetitive functions as well, but the downturn is that you can only use it in Maya

Python: Python is a scripting language that was brought into Maya 8.5, and it can do anything MEL can using the maya command engine (Remember import maya.cmds?). Whatever version of Maya you're using it has pre-installed the most stable version of Python that existed wheneve that Maya version was shipped. To check what version of Python your Maya is running type in this code:

import sys
print(sys.version)

The other upside of Python is that it has existed since 1980 so there's a huge online community and reference material available that isn't as thorough as MEL.

C++ API: This is basically just using C++ to manipulate things in Maya. It runs much faster, but you can use this API inside the Maya User Interface. You have compile the code in reference to what version of Maya you're using and then throw it into Maya within your computer (rather than inside of the application). Also I've heard that C++ is gnarly to look at it and learn. However if you want to try go for it...but this isn't the blog for you in that case.

Python API: This basically the way you can use Python inside of Maya. You can do a lot with Python inside of Maya, and this is what this blog is for. I could list out all the things you can do here and now...but that wouldn't really allow for this Blog to grow. So, now that you a few of the basics down let's go explore python in Maya in the upcoming months of blogging.

Thanks for reading. Again if you've got any questions my email is tleong127@gmail.com






Thursday, December 15, 2011

What's an API: A Quick Reference Guide



Hello!

So, if I haven't made it clear yet--I'm totally new to programming, and some words and terminologies scare me right off. I figured anyone else that's new to programming might have the same thoughts, so I'm here to provide (what I hope to be) a layman's glossary or reference guide for intimidating programming words (as I learn them!). For now I'm calling it a "Quick Reference Guide"...if I come up with a better name I'll totally change it for your entertainment purposes.

First up on the list: API

API stands for Application Programming Interface. The API is basically the ability to poke an application. In real terms it is an interface to communicate with the application, and make it do things you want it to.

Take Maya for example (Maya is an application). Maya has a two main interfaces (The GUI, aka buttons you click on to make things in Maya and the Script Editor). Now the Maya API responds only to Python and C++. That means that Maya has acquired a package of contents (which are the commands you use in each language) for you to tell it what to do. And then you as the programmer use that API (aka the commands) to write scripts to make awesome tools for the rest of the pipeline to use! Make sense? Hope so. Here's a little comic to help out what's going on.




Monday, December 5, 2011

How to make a directory in Python (Aka a Folder)

Hola!

I originally wasn't gonna do a post, but i figured it couldn't hurt. Though, as a heads up this particular lesson has nothing to do with animation. I learned two commands this week:

os.mkdir()
os.mkdir(os.path.join())

The first command makes a directory. The second puts directory B into directory A

Here's a short script that would make those two commands functional.

import os
#Makes it so that python can talk to the operating system
import os.path
#Makes it so that this script is user friendly in both Mac OSX and Windows

os.mkdir('Folder A')
os.mkdir(os.path.join('Folder A', 'Folder B'))

Now, this script will maker Folder A, and put Folder B inside of Folder A. I made this script to try and streamline a file creating system at work vs people copying and pasting folders all day.

How to Run when you're done:
1) Open the command prompt (Windows) or Terminal (Mac OSX)
a. To find the command prompt, just go to start and type in "command prompt" in that seach box (Windows)
b. Go to Finder > Applications > Utilities > Terminal (Mac OSX)

2) Change the directory to wherever you want your set of folders to be created
a. just type in:
cd [Name of Directory without brackets]

ex. cd Desktop
p.s. to go back a directory just simple type, cd..

3. Type in the path of where your python script lives
a. don't know the path? Right click and click on Get Info for mac users and Properties for Windows users
b. Paste the path into the terminal
c. Hit enter

Now if you didn't run into any errors you should have your folders sitting on the Desktop! If you did run into errors check to see why the computer is yelling at you, and try your best to fix it. Otherwise google the problem, or if you trust me email me at: tleong127@gmail.com

As I keep learning python I plan to add more features to this script, so stay tuned!

Thanks for reading, and have a nice day :)