The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.
So, ive been out of work for a while and im thinking its time to bone up on some new territory. I'm a 3D artist ( www.maverickpixel.com ) /shamlessplug, and i want to get into some coding that could help me through my ventures. I use Maya currently, and a few other programs. I know maya has Mel (maya's internal language, proprietary language for maya only. ) and now supports python. But im not sure what to go into. Python seems to be more universal, and mel... well ive watched mel tutorials and they seem really straight forward (let the prog write the code, then just copy it for later use. ). So, my first question what should i learn?!
and 2ndly, Where should i start? the only coding language i have experince with is HTML so its a whole new world out there for me.
MEL is out the door right now, Python is the new hot shit in Maya. Python is a great programming language. Google for some tutorials and practice. You should never expect a program (or a programmer!) to write your scripts for you, though. Go forth and make silly apps!
MEL is out the door right now, Python is the new hot shit in Maya. Python is a great programming language. Google for some tutorials and practice. You should never expect a program (or a programmer!) to write your scripts for you, though. Go forth and make silly apps!
Okay, so python, i understand the basic idea of strings, and what code does... But how should i use it in an application?
sorry for the vague question, im just trying to wrap my head around this..
Python seems to be the de facto language when looking at 3d modeling software integration and game scene testing, and there's PyGame of course. Because of this, it seems easy to find examples and resources from people making the same journey as you, so I think I'd have to recommend looking into that.
I'd recommend making really basic video game clones in PyGame using your own artwork, so that you cut your teeth on the whole tool pipeline (making assets all the way to integrating them into the simple game engine you write.) You'll learn that plus the basics of rendering, player input, game logic. Make a Tetris or Pacman clone etc.
I'm also interested in this. I've done quite a bit of Maxscripting (3DS Max's own scripting language) and now that I'm picking up Houdini and going into Visual FX I'd quite like to be able to do a bit of Python.
Can anyone suggest a decent site or a book that I could pick up?
Maverick, what you're talking about is 'Macro recording' and it's a semi-decent way to learn syntax (for example, if you want to create a Box via code you would turn on Macro-record, create a box and it would give you a like of code like "create.box $Box01" or whatever. Thats only one aspect of scripting, you will need to learn basic programming techniques before you're able to put this syntax into any real use.
So ive been reading this tutorial for about 5 hrs since last night, "a bit of python" and its helping, im getting the gist of the language... it seems alot like algebra.
but there seems to be some errors in the code that is provided and tutorials. here is an example. Showing the use of setting variables in the definition. which i understand. you set the variables for that loop block.
def printMax(a, b):
if a > b:
print a, 'is maximum'
else:
print b, 'is maximum'
printMax(3, 4) # directly give literal values #---here is where im getting a syntax error for the printMax(3,4)
x = 5
y = 7
printMax(x, y)
now im not sure why im getting that syntax error, but i think something as simple as this should work esp if its coming from a tutorial.
And, it seems everytime i save code, and hit ctrl f5 to run it. i get an invalid syntax error. and it highlights the text directly at the top that automatically appears when the shell is opened
[qoute]
Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
****************************************************************
Personal firewall software may warn about the connection IDLE
makes to its subprocess using this computer's internal loopback
interface. This connection is not visible on any external
interface and no data is sent to or received from the Internet.
****************************************************************
[/quote]
im not sure why its reading this when going to execute the program.
finally, when you do hit return/enter and something screws up.. are you supposed to restart the shell or just copy paste the old code and edit it?
Now, I've never coded in python but two things stand out to me, althought it might just be the formatting
1. do you need to end functions in python? I know in AS everything needs to end with a }
2. do you need a return statement at the end of your printMax function?
edit: also I'm not sure how Python reacts to whitespace, so printMax(3,4) might be different than printMax(3, 4), since your code has the latter and your syntax error has the former.
Give an enter at the end of your code blocks. Python is rather fussy with white spaces (it's format dependent) and sometimes that can end up in nastiness.
Also, if you are doing this in a prompt (like IDLE), stop doing that, they tend to screw up formatting all the time. Just type a script and run that.
Furthermore, I know absolutely nothing about MEL, but in my experience claims about having to learn something else before something are BS when it comes to programming languages. Actually, learning those 'gutted' languages, like the photo shop script, tends to be a detriment to your programming abilities.
At Imageworks we're using MEL and HScript (Houdini) in the FX animation department. Python's primarily used for proprietary apps, facility-wide.
That said, your mileage will depend on what you're trying to do - get better at a specific skill, be more able to jump between programs, just learn scripting to begin with? I've been picking up Python using Project Euler to strengthen my logic and math skills, and with some hope I'll be able to pull the syntax of Python into Houdini down the line. That said, in my experience native scripting languages have more support from the user base, so learning tutorials on MEL scripting for Maya is going to be infinitely easier than Python in Maya.
If I were just starting out and using Maya, I'd learn MEL first and jump into Python only when I started fooling around with the API. As for MEL, there's a good user reference book called "Complete Maya Programming". It won't blow your mind or anything but it's a great way to start.
That can often be the tough part. I'm a practical learner - it only really sticks when I'm doing something, and these books rarely do anything more than let me know something exists. With Maya it can be even more difficult to apply scripting when you're starting out.
The biggest place I use expressions right now are per particle expressions, but also scripts that do something to a batch of the same type of object. Some of the files I work with get up to 200 emitters, and I when I get a comment that says "less particles overall", you can bet your ass I don't want go go through and change each emitter so that they're emitting less. This is where MEL comes in .. pop open command prompt and type
$thing = `ls -type emitter`
for $each in $thing {
setAttr ($each + ".rate") 2
}
Suddenly something that should've taken twenty minutes took less than one. I would say learn the basics of scripting if you've never done any coding or scripting, but don't be afraid to see problems as things that have scripting as possible answers, and it'll start to add up.
Posts
Okay, so python, i understand the basic idea of strings, and what code does... But how should i use it in an application?
sorry for the vague question, im just trying to wrap my head around this..
I'd recommend making really basic video game clones in PyGame using your own artwork, so that you cut your teeth on the whole tool pipeline (making assets all the way to integrating them into the simple game engine you write.) You'll learn that plus the basics of rendering, player input, game logic. Make a Tetris or Pacman clone etc.
Can anyone suggest a decent site or a book that I could pick up?
Maverick, what you're talking about is 'Macro recording' and it's a semi-decent way to learn syntax (for example, if you want to create a Box via code you would turn on Macro-record, create a box and it would give you a like of code like "create.box $Box01" or whatever. Thats only one aspect of scripting, you will need to learn basic programming techniques before you're able to put this syntax into any real use.
but there seems to be some errors in the code that is provided and tutorials. here is an example. Showing the use of setting variables in the definition. which i understand. you set the variables for that loop block.
def printMax(a, b):
if a > b:
print a, 'is maximum'
else:
print b, 'is maximum'
printMax(3, 4) # directly give literal values #---here is where im getting a syntax error for the printMax(3,4)
x = 5
y = 7
printMax(x, y)
now im not sure why im getting that syntax error, but i think something as simple as this should work esp if its coming from a tutorial.
And, it seems everytime i save code, and hit ctrl f5 to run it. i get an invalid syntax error. and it highlights the text directly at the top that automatically appears when the shell is opened
[qoute]
Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
****************************************************************
Personal firewall software may warn about the connection IDLE
makes to its subprocess using this computer's internal loopback
interface. This connection is not visible on any external
interface and no data is sent to or received from the Internet.
****************************************************************
[/quote]
im not sure why its reading this when going to execute the program.
finally, when you do hit return/enter and something screws up.. are you supposed to restart the shell or just copy paste the old code and edit it?
thanks
-Mike
1. do you need to end functions in python? I know in AS everything needs to end with a }
2. do you need a return statement at the end of your printMax function?
edit: also I'm not sure how Python reacts to whitespace, so printMax(3,4) might be different than printMax(3, 4), since your code has the latter and your syntax error has the former.
Also you can use code tags to keep formatting.
but anyways im reading now that i should really know mel before jumping into python... Lucky me!
Also, if you are doing this in a prompt (like IDLE), stop doing that, they tend to screw up formatting all the time. Just type a script and run that.
Furthermore, I know absolutely nothing about MEL, but in my experience claims about having to learn something else before something are BS when it comes to programming languages. Actually, learning those 'gutted' languages, like the photo shop script, tends to be a detriment to your programming abilities.
That said, your mileage will depend on what you're trying to do - get better at a specific skill, be more able to jump between programs, just learn scripting to begin with? I've been picking up Python using Project Euler to strengthen my logic and math skills, and with some hope I'll be able to pull the syntax of Python into Houdini down the line. That said, in my experience native scripting languages have more support from the user base, so learning tutorials on MEL scripting for Maya is going to be infinitely easier than Python in Maya.
If I were just starting out and using Maya, I'd learn MEL first and jump into Python only when I started fooling around with the API. As for MEL, there's a good user reference book called "Complete Maya Programming". It won't blow your mind or anything but it's a great way to start.
now i just need to see a reason for altering things, so far ive made a button for a MR physical area light. whoo hoo
The biggest place I use expressions right now are per particle expressions, but also scripts that do something to a batch of the same type of object. Some of the files I work with get up to 200 emitters, and I when I get a comment that says "less particles overall", you can bet your ass I don't want go go through and change each emitter so that they're emitting less. This is where MEL comes in .. pop open command prompt and type
$thing = `ls -type emitter`
for $each in $thing {
setAttr ($each + ".rate") 2
}
Suddenly something that should've taken twenty minutes took less than one. I would say learn the basics of scripting if you've never done any coding or scripting, but don't be afraid to see problems as things that have scripting as possible answers, and it'll start to add up.