PDA

View Full Version : How can I start Layout.exe and run LScript file automatically ?



azzigoom
02-07-2013, 06:51 PM
How can I launch Layout and have is automatically run a script.

I can load a scene from the command line, but I am unable to figure out how to get a script to run.

For example, with the following Hello.ls file

@warnings
@name "Hello"
generic
{
info("Hello There!");
}

I can run this from a freshly launched Layout by selecting Utilities -> LScript and selecting the file.

But I have tried numerous guesses as a command line option to no avail.

For example neither
Layout -sHello.ls
nor
Layout Hello.ls

work for me.

Does anyone know how to do this?
Thanks
David

Lightwolf
02-08-2013, 04:17 AM
You can add a StartupCommand line to the layout config file to launch an LScript. However, the downside is that is required editing the config.

One way is create a backup of the config, add the line, run Layout, then copy the backup file back (from a batch file). Not simple but it works.

Two caveats:

Changed configs during that layout session will be discarded
If you exit the script hard, the backup config file won't be copied back and the StartupCommand will be stuck in the config until you manually remove it

Cheers,
Mike

azzigoom
02-08-2013, 03:02 PM
Partial success

For Layout
I needed to modify LW11-64.cfg to add StartupCommand Generic_Hello (on my machine is in C:\Users\myname\.NewTek\LightWave\11.0
and place Hello.ls into
c:\program files\newtek\lightwave\11.0\plugins\script\LScript

Note the somewhat unexpected 'Generic_' prefix on Hello!!

For Modeler, I need to add
StartupCommand HelloModeler

and create a HelloModeler.ls witih 'main' instead of 'generic' in it and place in
I modified LWM11-64.cfg to have a 'StartupCommand HelloModeler'

Note, this does NOT have a 'Generic_' prefix.


Also note that the line moves around inside the .CFG files on exit, which can be a little confusing.

Also if you have multiple instances,
the last one exiting will write the file, possibly restoring values you though you had changed already!

Thanks
David