Follow us on Facebook Follow us on Twitter Flickr Watch us on YouTube
Register
Results 1 to 3 of 3
  1. #1
    Registered User Mr. Wilde's Avatar
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    133

    Question Python documentation?

    I'm trying to wrapping my head around Expressions, LScript and Python Scripting, and yeah, I'm kinda confused because there's not much reference for Python scripting in LightWave. Where can I find examples, resources, docs? Can I use Python scripts in Expressions just as I can use LScripts in Expressions? What's the advantage of using Python over LScript?

    There's a video that shows an interactive chess game against a robot within Layout. Looks like Python scripting is extremely powerful and useful, yet there's virtually no proper documentation for it.

    As a complete beginner to scripting in LightWave, I feel pretty much lost here.


  2. #2
    Red Mage Celshader's Avatar
    Join Date
    Feb 2003
    Location
    Burbank, California
    Posts
    1,817

    Aiwebs 017 I feel your pain. I'm learning LightWave Python, too.

    Quote Originally Posted by Mr. Wilde View Post
    I'm trying to wrapping my head around Expressions, LScript and Python Scripting, and yeah, I'm kinda confused because there's not much reference for Python scripting in LightWave.
    I went through this EXACT same experience just in the past few days. I feel your pain.

    Where can I find examples, resources, docs?
    To learn Python itself, go to this page:

    http://wiki.python.org/moin/BeginnersGuide/Programmers

    I also recommend downloading one of the many free Python editors that highlight Python syntax. I use DrPython, but there's a ton of great options out there.

    To specifically learn LightWave Python, I recommend the following resources:

    • The Python Scripting section of the NewTek forum.
    • BigHache's video tutorials on how to write Python scripts for LightWave.
    • The "commands.html" section of the LightWave SDK. This will make more sense when you start using "evaluate(<command>)" for everything, because Python uses the exact same "evaluate" commands as C plug-ins for LightWave. You will find "commands.html" under "sdk\lwsdk11.0\html" in your LightWave 11 installation.
    • About 30-40 example Python scripts ship with LightWave 11. These are great for study. You will find these example scripts in the LW11 installation folder under "support\plugins\scripts\Python"


    Can I use Python scripts in Expressions just as I can use LScripts in Expressions?
    I don't know. I'm not sure about that one.

    What's the advantage of using Python over LScript?
    It ain't brevity. From what I've seen this week, LScripts are better for casual scripting. Python scripts follow more formal rules that are similar to C plug-ins for LightWave. For example, every Python script must include a list of credits at the top, every Python script must include installation instructions at the bottom, and every Python script must be formatted as a class instead of as a simple function like LScript.

    Where LightWave Python kicks LScript's *** is deeper access to LightWave, incredibly flexible built-in data types and third-party support.

    Because Python scripts follow the formal standards of C plug-ins, they get to enjoy C-level access. LScript does not have access to everything that C plug-ins do in LightWave. LightWave Python does.

    The native Python data types and methods are an absolute joy to use in a script. You can mix and match its lists and dictionaries to tackle any problem you might find. You can use slices and negative indexes instead of having to write custom functions to do the same things. Python also ships with at least a hundred stock modules that a coder can drop into his script at any time. I can't say enough good things about the Python language itself.

    The third-party support of Python is mind-blowing. If you need to tackle a specific problem, chances are good that a common language like Python already offers a third-party solution for free. For example, there's third-party modules out there that make it easy to read and write OpenEXR data. The chances of finding third-party support for a proprietary language like LScript are slim.

    As a complete beginner to scripting in LightWave, I feel pretty much lost here.
    I'm almost in the same boat. I do know Python scripting, and I've used it since 2006 to edit LightWave files outside of LightWave. Until this year I've only written one LScript for LightWave, and that was just a script to launch an external Python script to process the LightWave scene file.

    I've always been lost when it came to programming and scripting tools meant to be used inside LightWave. I did not understand most of the SDK documentation or tutorials that I did find, and I never found the "right" documentation to help me learn how to write LScripts. I only learned last month about Mike Green's amazing LScript Index, for example.

    That said, a day or two of with LightWave Python did bring results. I started with the "add_null.py" script that ships with LightWave to see how much code I could strip out before the script stopped working altogether, and I studied the error messages I got on PCore. I also used the PCore console to save out help files, and I asked questions on the Python Scripting forum here on the NewTek site whenever I've been stuck. The more knowledgeable people on that forum have been generous with their time and with their experience, and they helped me a lot.

    "add_null.py" made a lot more sense to me after a day of studying it. However, if you do not already know Python you might be confused by the ServerRecord dictionary at the bottom, the ServerTagInfo list of tuples above it, the "import lwsdk" command at the top and the use of a class to define "add_null" itself. If possible, I recommend learning Python scripting before you learn LightWave Python scripting. As you advance in Python, consider writing tools that analyze and/or process the text of LightWave scene files. That will get you familiar with Python basics like lists, splits, find(), read(), and write(), and you can start using Python externally in a LightWave pipeline before you advance to writing internal LightWave tools.
    Jen's 3D -- LightWave stuff.
    Jen's 2D -- my comic book.

    Python is my smashing board. LightWave is my S.M.A.K.

  3. #3
    Registered User Mr. Wilde's Avatar
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    133
    Thank you so much. That's a great help.

 

 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 02:07 PM.
Powered by vBulletin® Version 4.2.0
Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.
Copyright 2000-2012, NewTek
vBulletin Skin By: PurevB.com