PDA

View Full Version : Wrapping my brain around it...



MentalFish
08-21-2012, 11:01 AM
I have always loved the simplicity of "scripting" languages such as JavaScript, Lingo in Macromedia Director, C# in Unity, and I think it is great that LW has adopted the VFX industry standard scripting language Python. That said, does it really have to be so "elaborate" at every point and turn?

LScript: lyrsetfg(2);

Python: cs_options = lwsdk.marshall_dynavalues('2')
cs_setlayer = mod_command.lookup(mod_command.data, "SETLAYER")
result, dyna_value = mod_command.execute(mod_command.data, cs_setlayer, cs_options,lwsdk.OPSEL_USER)

Question: is it possible to make this shorter, with some sort of dot syntax access to functions similar to lyrsetfg, or does it have to be 3 lines pr command in Modeler? It's all fine and dandy that there is extra padding on either side of the business bit of the script, but I would love to see more explanation of marshall_dynavalues and the other bits and bobs in here.

:help:

skarloc
08-21-2012, 01:10 PM
I haven't yet done much in modeler, but I have done a fair bit in layout (which may be easier, I don't know). I did find the number of lines of code to do stuff quite high and I have done a lot of wrapping to make it easier for me.

I'm not a great Python programmer either, but I do believe it's quite a "verbous" language. I'm not sure you could make it easier to use, with less lines...

Maybe the SDK should include more wrappers to take the "headaches" out of the programming.

BTW, any chance of a snippet of code that moves selected points/polygons 1mm in the X axis ? I haven't even been able to do that ! (Thanks in advance)

Dodgy
08-21-2012, 07:28 PM
I have to agree. Stuff which was very short in Lscript seems to take much longer in python. Still, as they say, it is an industry standard...

Plus I so prefer brackets instead of indents. My favourite text editor displayed the indents incorrectly, so I was chasing my tail for half an hour trying to sort out a bug. Plus if I want to loop out a section in lscript I just comment out brackets, but I have to unindent a whole section in python, which can lead to more errors when I indent it again. Seems a pain for bug fixing :P

skarloc
08-24-2012, 03:47 PM
Plus I so prefer brackets instead of indents.

This was one of the reasons why my former company initially rejected Python in favour of Perl - too easy to make mistakes and code is less easy to read (IMHO).


My favourite text editor displayed the indents incorrectly, so I was chasing my tail for half an hour trying to sort out a bug.

What do you use ? I use wscite, which seems to work well (well, I've not had any problems). At my new work, they're all Linux and Mac and they prefer vim... Which does the trick as well.

BeeVee
08-26-2012, 04:30 PM
Perhaps Bob Hood's LScript to Python converter would be useful? It normally sits here: http://www.lucidgears.com:21134/ but it seems to be offline right now.

B