Learning Python - LIP

Python scripting resources
User avatar
Vitor Teixeira
Posts: 312
Joined: Thu Jul 23, 2009 1:47 pm
Location: Porto, Portugal
Contact:

Learning Python - LIP

Postby Vitor Teixeira » Sun Jul 25, 2010 10:20 pm

L(earning) I(n) P(rogress)

Hello everyone,
I want to learn Python.
My main tools are Maya, RF, Max & Nuke and Python is used by all of them. Not that I feel obligated to learn it but I think it's crucial. I'm starting this thread because from my previous experience, in this great forum, is that I'll learn more and fastest when providing what I learn and from feedback from all who which to participate. The rain drop was a great example, like the other threads I've started. This forum has been, in the last year, the most important place for me to improve my skills has a Fx Artist.

My objective here is to learn and to provide and this thread will be my main guide to it.
I'll post all my tests and my frustrations here like a logbook until I achieve a basic comfortable level. So, let's start with this adventure.

I'm reading Scripting in RF4 at the moment, this was the first advice I got a couple of months a go. I hope this is a good choice.
I've started with some research, some of the DVDs I already own like some books too, others I'll probably buy like the RF Magazine.

http://www.python.org/
http://beta.td-college.com/courses
http://rf-magazine.com/2_issues/issues_scripting_01.html
http://www.digitaltutors.com/09/training.php?cid=31&view=all&sort=creation_date
http://www.fxphd.com/courseInfo.php#PYT101
http://www.amazon.com/exec/obidos/ASIN/0596513984/fxguidecom
http://tutorials.realflow.com/
http://cmivfx.com/productpages/product.aspx?name=INTRO_TO_PYTHON

I'll start posting my results as soon as I can.
Cheers


lukeiamyourfather
Posts: 2880
Joined: Mon Oct 15, 2007 4:09 pm
Contact:

Learning Python - LIP

Postby lukeiamyourfather » Mon Jul 26, 2010 1:58 pm

Vitor Teixeira wrote: Not that I feel obligated to learn it but I think it's crucial.

Yes, it is crucial and its good that you're on that track. Many artists avoid scripting thinking its not necessary, why people think that is beyond me. In reality the artists with scripting experience often end up saving the day with a twenty line script. Guess who gets to stick around for the next show? Its not the guy who spent four days renaming thousands of nodes and exporting an OBJ for every frame manually. :ninja:

User avatar
Vitor Teixeira
Posts: 312
Joined: Thu Jul 23, 2009 1:47 pm
Location: Porto, Portugal
Contact:

Learning Python - LIP

Postby Vitor Teixeira » Mon Jul 26, 2010 8:47 pm

Can I study tutorials that teach Pythn in RF 4?
His this a good idea?
Does it changes a lot from one version to another?
Thanks


I think I'll buy the CMIVFX Intro to Python cause the critics I have read over the net were quite good. Since my main objective is to learn it an to adpte to different softwares maybe this is a good choice. If anyone had already tried it, please give a ring about it.
Cheers

User avatar
Vitor Teixeira
Posts: 312
Joined: Thu Jul 23, 2009 1:47 pm
Location: Porto, Portugal
Contact:

Learning Python - LIP

Postby Vitor Teixeira » Tue Jul 27, 2010 10:57 pm

First steps:

Scripting in RF 4

.Introduction
"open-source"
www.python.org

.Preliminaries: Get Python
Functionality of some modules is dependent of the version.
Import of the Site Module.
Sitecustomize for additional modules.

Overview of Python Scripting in RF4
.Areas of scripting

5 places:
- Events (start & end, each frame, each simulation step; default is empty "do nothing");

- Daemons (apply forces to particles, killing particles or applying forces to scene objects);

- Realwave (sequence of grayscale image maps as the source of the wave field);

- Batch / command line scripts (here you can do almost every thing (load scenes, save out new versions or create scenes from scratch) and have access to all parameters within a scene);

- Scripted fluid behaviours (personalized fluid behaviour).

.Order of scripted operations
Script daemons are applied every simulation substep;
The order of operations is most important In the events scripts;
When the calculation reaches a frame boundary - order (calculations of the simulation substep, then onSimulationStep script, then the particle and other data is writen out and then onSimulationFrame script runs.
Order is very important when we want to act or do something to the particles each frame, instead of saving them. Play attention to the export Central option.

.Limitations
- Only with batch script we can create or load a new scene, jump to other frames, simulate individual or ranges of time substeps or frames;

- Single thread;

- We can't script preferences, fps and adaptive stepping settings;

- Others limitations are mentioned, but is also refered that that certain limitation will be removed, I hope in RF 5 this is over, so I will not mention them.

.Generalities
Basics of Pytho
n
I say you follow but in a specific and particular order.
"High level" programming language.
The role of the Python Interpreter in all the structure.
Write always notes of what you do and make the scripts recognizable.

Getting objects and their attributes
Python is object-oriented.
Emitters, particles, scene objects and vectors all have associated attributes and functions.

Acessing att of objects in Python, the general way to do it
Ex: getting the position of an sphere (named "sphere01") or any other object in the RF scene:
scene.getObject("sphere01")
Ex: getting the position of an daemon (named "diablo"):
scene.getDaemon("diablo")
Ex: getting the position of an emitter (named "emirates"):
scene.getDaemon("emirates")

String = "any set of characters within here"

In RF we have to access objects, hierarchically, starting with the highest level object: the scene. Ex: scene - sphere - faces.

Assigning variables
Assignment variables:
myvalue = 2.8
Now we can use myvalue, since we have declared it, we always need to declare before we use it.
newvalue = myvalue*2.9 + 83

Floating points = 1.3, 2.9, etc
Integers = 1, 2, etc

We can't use floating points has a index of a list. It's possible to convert integers to floating points, floating points to integers and floating points or integers to strings.

Assignment statements: it's important to re-lable if you intend to refer it in several places.
Ex: Variable "chair" is defnined at the beguining,
chair = scene.getObject("sphere01")
now it can be used several times, just by typing "chair".

Ex: Getting the position,
with variables
chair.getParameter("Position")
without variables
scene.getObject("sphere01").getParameter("Position")

Vector in RF is a 3 element sequence of floating point (x=2.0, y=0.0, z=0.0). Vector quantities involve position, rotation and scale, any velocity and any force.

User avatar
Vitor Teixeira
Posts: 312
Joined: Thu Jul 23, 2009 1:47 pm
Location: Porto, Portugal
Contact:

Learning Python - LIP

Postby Vitor Teixeira » Wed Jul 28, 2010 11:51 pm

Step by step i'll be adding some new content to this thread.
I bought the learning Python from CMIVFX it seems very cool.
I'm really enjoying studying this but I'm not even scratching the surface.
Cheers


Return to “Python Tutorials and Resources”

Who is online

Users browsing this forum: No registered users and 1 guest