Login|Register   
   Home |  Active Topics |  Members |  Search Forums |  FAQ     
  All Forums >>  Site Discussion  >>  Scripting for newbies
   Printer Friendly  New Topic     Reply to Topic
Author Previous Topic Topic Next Topic  

pBarrelas
Member

6 Posts

Posted - 04 Jan 2010 :  00:26:17  Show Profile  Visit pBarrelas's Homepage  Reply with Quote

Hi everyone! First I want to thanks Gwynne for all the time and effort put on all the scripts freely available for the Modo community.

Since I don't have any scripting knowledge, I think it would be very helpful to see some tutorials on Python and Modo, in order to help newbies to start on this world. I'm referring Python because that's the language I want to learn and because it can help to bridge Modo and several other applications.

If this isn't possible, what advices can be given to me in order to start? Please don't tell me to read the Python documents (although that is necessary), because I tried it once and lost motivation, so I'd like to start learning it but seeing results in Modo, in order to be more joyful.

Thanks

pBarrelas
Member

6 Posts

Posted - 04 Jan 2010 :  07:12:18  Show Profile  Visit pBarrelas's Homepage  Reply with Quote

I think I'll keep here posted all the steps I'm taking on this endeavor in order to help others.

So in order to start Python scripting for Modo:
-Download the latest Python version at http://www.python.org/download/
-I'm using Free Komodo Edit to write the scripts. You can find it here:http://www.activestate.com/komodo_edit/;
-In Modo goto Layout > Windows > New Window, a new window pops up and now you have to turn it into the Event Log by clinking on the top right little arrow and chose Event Log. This is where we can see what Modo is doing behind the curtains and really useful to get feedback when we're scripting;
-Now we just need to clear the log from all previous info by clicking on Clear Log > Master List > Yes;

My first script:
-Open Komodo Edit and choose File > New > New File, a window pops up and choose Python from right pane and choose to save it as *.py file at your user Modo scripts directory (in Win Vista/7 C:\Users\Your Name\AppData\Roaming\Luxology\Scripts. I name it test_script.py;
-In Komodo I deleted the default line #!/usr/bin/env python jut to maintain the code clean;
-Type #python in order for Modo to recognize it as a Python script;
-Type import lx in order to import Modo's Python module;
-Type lx.out('Hello World!'), this prints to the Event Log whatever you have inside the (). Text needs to be inside '';

The code looks like this:
#python

import lx

lx.out('Hello World!')

-Save it and inside Modo goto System > Run script... (Shift+F5) and pick your script. On the Event Log you'll get Hello World! printed out along withe the useful info about the location and script just executed.

HOORAY!! I'm actually impressed by what I just achieved. My 1st well succeeded Python script for Modo. Now the sky is the limit.


Edited by - pBarrelas on 04 Jan 2010 07:27:11
Go to Top of Page

pBarrelas
Member

6 Posts

Posted - 04 Jan 2010 :  07:39:52  Show Profile  Visit pBarrelas's Homepage  Reply with Quote

I found this link at Luxology's forum from GwynneR that will help beginners like me: http://forums.luxology.com/discussion/topic.aspx?id=17178&show=scripts

Although I didn't completely understood the 2 different ways to interact with Modo's internal comands and advantages/disavantages using each. Can someone help?

Edited by - pBarrelas on 04 Jan 2010 07:50:57
Go to Top of Page

Gwynne
Admin

69 Posts

Posted - 05 Jan 2010 :  18:37:31  Show Profile  Visit Gwynne's Homepage  Reply with Quote

Hi Paulo, scripting tutorials are something I've thought about doing several times but I never seem to have the time to do them - that and I find it hard to put myself into a beginner's frame of mind so it's hard knowing where to start.

a couple of things from your posts though:

Here's the custom scripting viewport that I use. Unzip the file and put the config file in your user configs directory. Then open/restart modo, click on the '+' sign next to the render tab and choose 'Utility/Scripting' from the menu. You'll now have a new tab called 'Scripting' with a viewport containing the most usefull bits and bobs for most scripting exercises.

Scripting Viewport

If you're using modo 40x then you don't really need to install Python separately unless your chosen IDE requires it. Komodo has it's own Python, or at least Komodo IDE does.

If you're writing single file scripts you don't need to explicitly import lx, it's done automatically. If you're writing packages or modules to import from then those do need to import lx.

And, finaly, kudos for having a go, stick with it :)
Go to Top of Page

Gwynne
Admin

69 Posts

Posted - 05 Jan 2010 :  18:45:52  Show Profile  Visit Gwynne's Homepage  Reply with Quote

quote:
Originally posted by pBarrelas

Although I didn't completely understood the 2 different ways to interact with Modo's internal comands and advantages/disavantages using each. Can someone help?

I'm not totally sure what you're referring to, do you mean what's the difference between using lx.eval() and lx.command()?
Go to Top of Page
  Previous Topic Topic Next Topic  
   Printer Friendly  New Topic     Reply to Topic