Friday, January 10, 2014

How to Setup Sublime Text 2 and Sublime Text 3 to syntax highlight MEL (Maya Embedded Language)

Hello There,

*Tutorial starts at BOLD type*

I have a consistent problem with updating my blogs. It's just been really difficult to stay on top of things. Life's been a little busy. However, I'm entering a time in my life where I'm able to balance active learning again, and so I'd like to start updating this blog again!

How to get MEL (Maya Embedded Language) syntax highlighting in Sublime Text 2 and Sublime Text 3.

To start this post off I didn't put together this tutorial. I just wanted to do a quick post with a link to a great tutorial, so that it has more exposure. It doesn't hurt right to duplicate a source right (as long as credit given to the original author!)?

Here is a link to Danny Wynne's tutorial "Sublime Text 2 and Maya Setup Guide".

Thank you so much Danny for figuring this out, and posting it!!

http://www.dannywynne.com/blog/?p=66#comment-7254


Thanks for reading,

Teresa

P.S. I do not know Danny. I am simply re-publishing his tutorial to attempt to give it additional exposure!

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 :)

Wednesday, November 23, 2011

I Don't Just Watch Movies All Day, and brief lesson on Python Operations


When I was little I wanted to be an engineer cause I liked building things. At some point I felt that that would be too difficult (just wait for the irony), and I fell in love with animation dream got derailed. I went to school to be an animator, and all my friends were jealous that my homework involved watching movies and almost no papers. Three years passed, and I discovered I actually like the technical aspects about the animation pipeline versus the actual animating (but don't get me wrong I do still enjoy animating..I just like the other thing better). It's been six months since I graduated from college with a degree an animation, but its day one of my serious journey to figure out this technical animation nonsense.

PYTHON LESSON, YES PLEASE! (Variables, Printing, Strings)

Ok, I don't know where everyone might be in their programming knowledge. If you're brand new to programming, and remotely trust my knowledge feel free to email me at tleong127@gmail.com. Put in the subject line what you want claifications on.

I have been reading this book: http://www.amazon.com/Maya-Python-Games-Film-Reference/dp/0123785782 (Maya Python for Games and Film) in an attempt to teach myself Python Scripting.

I'm at chapter two, and it's the first programming language I've ever attempted to learn.

Python inside of Maya can call upon certain commands related to Maya. Before you run any python scripts in maya you must type:

import maya.cmds

now say you wanted to make a cube by scripting:

maya.cmds.polyCube()

#if you're in the script editor hit Ctrl+A (To select everything) Shift+Enter (on the numpad) to run the script and keep the script present in the script editor. However if you're ok with the script being erased, and just run in the computer go ahead and just hit Enter (on the numpad).

#The number sign is how you comment in Python

So far the coolest thing about Python is how easy it is to assign variables. You can assign almost anything to a variable:

x can equal any of the following things:

x = 5
#This is an interger
x = 5.0
#This is known as a float
x = 'Python is fantastic!'
# This is a string
#A string is just a group of words enclosed by either '' or "". You can use quotes interchangeably, just make sure you're consistent!
#However you can't mix numbers and strings together. If you want to do that you'll have to let python know that you're converting one to the other.
#Here's how you'd do that:

#Say you want to print out the sentence "there are 3 kittens in the park."
#and you have:
x = 3

#if you go:
print('there are ' + x + 'kittens in the park.'
#an error with pop up: Error: typeError: file ,maya console/ line 1: Cannot concatenate 'str' and "int' objects
#However if you change it to:
print('there are ' +str(x)+' kittens in the park.')
#you should get
there are 3 kittens in the park
# Now you can also do that vice versa with declaring something as an int() versus a str() or a float()

SKIPPING AHEAD TO OPERATIONS!

You can do math in python too! I'll start off with just basic math operations (multiplication, divison, subtraction, and addition). Though remember that Python follows the same of order of operations you learned in middle school alongside with Algebra. Time to remember: Please Excuse My Dear Aunt Sally. Of course that is the mnemonic device to remember: Parentheses, Exponents, Multiplication, Division, Addition, Subtraction (in that order!!)

Quick Reference:
x + y The sum of x and y
x - y The difference of x and y
x*y The product of x and y
x/y The quotient of x and y, if x and y are integers the answer is rounded down
x//y Floored quotient of x and y, if x and y are float numbers the result is a float number
x%y quotient of x and y with a remainder
pow(x,y) x to the power of y
x ** y also x to the power of y

With that it's pretty fun to go find some word problems and try to solve them using python
here's a site with Word Problems: http://www.mathplayground.com/mathhoops_Z1.html


Sample:
Matthew has a lot of baseball cards in his collection.
He began his collection when his dad gave him 45 cards for his eighth birthday. Matthew won 15 cards during a game.
He bought 20 more cards at the Sport Court.

How many baseball cards are in Matthew's collection now?

cards = 45

cards += 15

cards += 20

print(cards)

80


#There's two things I forgot to mention. One Python is a dynamic programming language, meaning you can always update/change the variable on the next line. But be careful and make sure you WANT to change the variable before you do so. Also if you type an operation before the equals sign when you want to assign a new number to a variable python will just do that operation to the original variable to give you the new variable.

I hope you enjoyed the lesson and it was somewhat useful. Again as I keep learning I'll keep posting. See you next time!