PDA

View Full Version : Python in lightwave



dsolo
02-16-2012, 04:36 AM
Besides the python console button, I can't find any info about how to create python scripts for Lightwave.
Could anyone bring some light to this matter?
Sdk documentation lacks any info about how start with this.
I have previous experience in maya but I can't figure out how to work in lightwave.

Thanks in advance.

Red_Oddity
02-16-2012, 06:05 AM
Chuck posted detailed instruction on how to create Python plugins/script here :http://forums.newtek.com/showthread.php?t=123672

To check out some working examples, go to your LW 11 install directory, from there :
\support\plugins\scripts\Python\

dsolo
02-16-2012, 06:15 AM
Chuck posted detailed instruction on how to create Python plugins/script here :http://forums.newtek.com/showthread.php?t=123672

To check out some working examples, go to your LW 11 install directory, from there :
\support\plugins\scripts\Python\
Thanks, too bad I don't belong to the Core community, so I can't get acces to that info. I think maybe now that lightwave 11 is officially out they can make public these info.

BigHache
02-16-2012, 08:55 PM
Here is the info that Chuck posted in the Core forums. Should be okay to post, there's nothing special about it. If I'm wrong, that's why we has a sheriff.

I'm working on writing my own doc and started a video series, but I'm learning Python at the same time so it won't be super fast coming.

dsolo
02-17-2012, 02:48 AM
Thanks a lot! That's what I was needing!

nurbman
02-17-2012, 04:35 PM
I'd like to know more about Python in LW also.

I did some lscript a few years ago and found it very tricky. I wanted to turn lights on and off during an animation, but it turned out that the scripts would randomly run several times per frame. I had to keep track and ratchet through the scene - so that the script would run only once per frame.

Is Python in Lightwave 11 able to do the above where you can easily change object location, shape, color or other parameters depending on what frame you are in. ie: if frame = 10: do this ...

This would allow procedural animation/motion graphics using code rather than manual keyframing.

Matt
02-17-2012, 08:21 PM
You would need to track which frame you're on, and do something based on that.

Also, Python has full SDK access, whereas LScript doesn't.

There is currently no specific documentation on writing Python in LScript beyond the commented examples, this is something we naturally want to address, it's just a very time consuming job that would have been impossible to have done for the release.

BigHache
02-18-2012, 12:20 AM
@nurbman Tagging in on what Matt said, if you look at the C SDK you can get an idea of how to do what you're asking, probably more so than by looking at the LScript docs.

For instance, these two classes are very similar to the C SDK docs:

lwsdk.LWLightAccess

lwsdk.LWLightInfo

Understanding how to convert the C SDK to Python syntax is the kicker right now. To answer your question, is it possible to do with Python, I think the answer is Yes, I'm still learning this myself though.

evenflcw
02-18-2012, 10:44 AM
@nurbman
From the sound of things you did not use the right type of plugin class and you did not use it the right way. Perhaps it's the fault of documentation, but I doubt it was the fault of lscript! Some plugin classes can be called several times a frame. This is not the fault of lscript, but a result of how LWs architecture is setup and it is not wrong in any way. It will also be the same for all plugin-platforms!

What properties can be animated safely during animation is any property that has an envelope! You could animate other properties, that are set by commands, but realize that you are attempting to change LWs state mid-render, resulting in possible crash or no effect at all. For example there is an animatable limited region script which does this (a master, provides an envelope, then issues the command as need be). Unless LW was recently "fixed" I do not believe it worked when network rendering. It would be wonderful if we could animate anything.

nurbman
02-18-2012, 10:00 PM
I wasn't able to animate a random pattern of blinking lights probably due to the envelope issue (or my lack of knowledge). Moving a lit object in lscript, every 10 frames -instantly, did work though.

I'm hoping that the Python/sdk addition will give some additional freedom to do more stuff in code - but I realize that there are limits due to the nature of the animation/rendering pipeline.

Feel free to mention any newly discovered abilities that the addition of Python allows. (or point to any new documentation)

Thanks for the replies

Jure
02-27-2012, 06:09 AM
I wasn't able to animate a random pattern of blinking lights probably due to the envelope issue (or my lack of knowledge). Moving a lit object in lscript, every 10 frames -instantly, did work though.

I'm hoping that the Python/sdk addition will give some additional freedom to do more stuff in code - but I realize that there are limits due to the nature of the animation/rendering pipeline.

Feel free to mention any newly discovered abilities that the addition of Python allows. (or point to any new documentation)

Thanks for the replies

Take a look at samples provided in plugins/scripts/python folder. You can learn a lot from those examples. Also it seems that you can querry pretty much anything that is available in LW SDK with python so take a look at SDK docs and examples also.

Burchigb
02-28-2012, 04:54 PM
BigHache,

Thanks for the vids so far. Like how you are doing them. Make sense and it is easy to follow.

Sensei
02-29-2012, 02:35 PM
I'd like to know more about Python in LW also.

I did some lscript a few years ago and found it very tricky. I wanted to turn lights on and off during an animation, but it turned out that the scripts would randomly run several times per frame. I had to keep track and ratchet through the scene - so that the script would run only once per frame.

Is Python in Lightwave 11 able to do the above where you can easily change object location, shape, color or other parameters depending on what frame you are in. ie: if frame = 10: do this ...

This would allow procedural animation/motion graphics using code rather than manual keyframing.

Your problems are related to lack of knowledge.. Even C/C++ plugin can't do what you want. So, python or lscript, which are another layer above plugins won't do it too. If they will work, it will be by accident, and only in some rare situations. f.e. it won't work on render farm, or won't work when image-sequence is rendering from middle.

Your plugin/script should be run once and make envelope with keys to 0 and 1.

Plugin classes which can be run during rendering are: nodes, shaders, volumetrics, image filters and pixel filters. They need speed, which any interpreted language cannot give them. Who wants to have 100 times slower rendering?

Gorbag
03-01-2012, 09:19 AM
Also, Python has full SDK access, whereas LScript doesn't.

Well, certainly "fuller" access to the SDK. To be sure, there are still elements and plug-in classes that I've not yet implemented.

ednachman
03-01-2012, 02:21 PM
"\support\plugins\scripts\Python\" There aren't any files, that I can find, that would show examples. Every folder under "Layout" and "Modeler" contain empty folders. How do I get to the examples?

Jure
03-01-2012, 02:31 PM
"\support\plugins\scripts\Python\" There aren't any files, that I can find, that would show examples. Every folder under "Layout" and "Modeler" contain empty folders. How do I get to the examples?

That's where I find them on my system. No idea why yours is empty... Try searching for .py files.

ednachman
03-01-2012, 07:07 PM
Finally found them.

ednachman
03-02-2012, 03:57 PM
BigHache: In your first video I am having a problem reading your input. This is what I see: lwsdk.LWMessageFuncs().info("Hello World!". None) After this input, I don't get anything.

BigHache
03-02-2012, 10:00 PM
("Hello World!", None)

Should be a comma. info() takes three arguments: self, char arg1, char arg2. You can always double check with help() to make sure you're using something correctly.

Because of the tininess of code on the screen like that, the other videos have the code biggerer. This was my first attempt at a video tutorial.

ednachman
03-03-2012, 05:22 AM
BigHache! First attempt was very helpful. Keep it up. I sure appreciate your effort.

ednachman
03-03-2012, 06:23 AM
I finally got the message to work but the output is at the bottom of the Modeler Screen as a phrase; no "Okay"

evenflcw
03-03-2012, 09:08 AM
Whether you get it in the message field or a separate window depends on the Alert Level you have set in the interface options in Modeler and Layout. Ie it's a user preference and something the script should respect. So all is good.

BigHache
03-03-2012, 09:42 AM
Yeah sorry about that. That was something I forgot about when I made this example. I put a note about this in the video description.