12 December 2010, 11:15 AM
Just my $0.02
Scripting is of course a big subject, but first and foremost it is a matter of breaking down the "big picture" into smaller sub-problems. Then when the sub-problems are simple enough, you start combining the results from them and in the end you have a construct that solves the pig picture.
Anyway, I'm not a python man myself, I so I speak from the MEL perspective, however the methods are the same.
First your homework; read the python manual - familiarize yourself with variables and loop constructs/controls structures. Then do a quick read through of the Maya python command documentation. A big one, but necessary. However you don't need in this step to know how all commands work. It is more important that you know OF them, then when you stump upon a problem you can read up on the particulars of the command you think might solve the problem.
Then scripts are like onions (bad one - I know :) ) - they have layers.
Start at the very core of your problem, test if you can create a script which sets a keyframe on the joint given some input parameters - have all parameters specified in the function prototypes (i.e. no `ls -sl`in this function). Do this in a "clean" scene - i.e. a scene with just a joint or two - nothing that you can break if things go wrong.
If you can do this, you then have the core layer of you script; a function that sets a keyframe to a specific angle.
Then add the next layer; write a function that calls this "core function" with different angles in some kind of "for" or "while" loop, you will then most likely have very much the same parameters to this function as you had to your core function, however instead of a single angle, you supply it with a range.
Then wrap this function in an outer layer that decodes user input (i.e. put your `ls -sl`statements here). Give some thoughts on how to supply values; your parameter"rx=0 - 90" might be hard to decode, perhaps the combo "-attribute='rx' -min=0 -max=90" would be easier to process.
Anyway. Finally; some of these functions might be tiny and then you might as well combine it with the layer "above". For instance the "core function" might only be a single command, and then it is better to integrate it into the loop.
As I said, it is a big subject and there are many approaches, but in the end it is all about breaking down the problem and solving the pieces. Knowledge of the API (i.e. the commands) will guide you in the problem break-down. If you don't know the commands, you won't know how the problems can be solved.
12 December 2010, 11:15 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.