PDA

View Full Version : Help creating a startup script for Layout



MrFurious
07-20-2015, 10:24 AM
Hi all, I'm tired of always having to manually open the scene editor, motion options, preset shelf and a couple other panels every time I open LW (to complete my gui setup) which is annoying since some of the panels open by default on launch ie. graph editor, image editor, surface editor.. yet others do not. Apparently it's possible to add a startup command to the LW config file so a script is run on LW launch and I'm thinking this is probably the way to go about this. I wonder if anyone can help me write a script or at least point me in the right direction with a subset of commands which would be needed for something like this?

Basically I'd require the script to do this at launch:
(applies to all panels: scene editor, preset shelf, graph editor, surface editor, image editor, motion options)

- check if the panel is not open already
- if not open, open the panel
- enable octane plugin
- open octane editor.

That's pretty much it, very basic but just knowing where to start is a problem for me.

Marander
07-20-2015, 12:13 PM
Can't help you with the script but for the meantime you can add at least the Scene Editor to Master Plugins. There is also a built-in plugin to define the individual windows sizes and positions.

iain_r
07-20-2015, 02:22 PM
Hi,

If you load the lscript lscommander from the utilities tab and then load the various panels that you want to have opened you can see the commands that are issued. It you drag these commands into the editing window, select the session drop down and convert to lscript it will give you the basics of a script. I did the following quickly to show what can be generated.

I didn't copy all the lines into the command window. Not all panels allow access to the tabs via code, it depends on the server. If you search on the forums I think you can find the instructions on how to auto execute an lscript on startup.

You can save the following as an lscript as a start point.

Regards

Iain


@version 2.8
@warnings
@script generic
@name "StartOptions"
generic
{
ApplyServer("MasterHandler", ".SceneEditorStandardBanks");
ApplyServer("MasterHandler", "SceneEditor");
EditServer("MasterHandler", 4);
GraphEditor();
SurfaceEditor();
ImageEditor();
Presets();
}

spherical
07-20-2015, 03:50 PM
some of the panels open by default on launch ie. graph editor, image editor, surface editor.. yet others do not.

I hate that. Uhhhh.... doesn't seem like consistency would be a huge hurdle; other than recognizing that there isn't any. Properties panel is my peeve. Surface, Scene, Image all open in the position where I set their windows; leaving a big void where Properties was. Requested many times. Goes ignored through, heck, a dozen+ versions/updates, now?

iain_r
07-21-2015, 06:30 AM
I've updated the script so that it will not close a panel if it is already open, but will open it if it is closed. The presets command does not understand the parameter so it will either close or open depending on what state the current panel is in. The motions panel will cannot open unless an item in the scene is selected. By default the scenes current item is an object, in an empty scene this is [none], so the motions panel will not open and the button is not enabled. If you want a different scene editor replace the two ApplyServer and Edit server lines with the single line

CommandInput("SceneEditor 1");

Spherical, the same applies to the properties panel, if you do not have anything selected in the scene you will notice that the properties button is not enabled.

Regards

Iain


@version 2.8
@warnings
@script generic
@name "Start2"
generic
{
ApplyServer("MasterHandler", ".SceneEditorStandardBanks");
ApplyServer("MasterHandler", "SceneEditor");
EditServer("MasterHandler", 4);
CommandInput("GraphEditor 1");
CommandInput("SurfaceEditor 1");
CommandInput("ImageEditor 1");
Presets();
}

spherical
07-21-2015, 04:29 PM
Yes, that rang true when as read the first paragraph and the behaviour then made "sense"; not that this condition makes any actual sense in the logical useability realm. And the simple solution is that every scene has a light and a camera. Yet, the Devs choose to enable a button that does NOT necessarily have anything to be selected by default. Why am I not surprised? This, then, begs the question: Is there any way to programmatically change the active button from Objects to Lights or Cameras?

The bigger question, of course, is: Why do we have to resort to these needless, useless, time consuming workarounds when the issue could have been dealt with long ago in the basic code by having a button selected by default that always has something TO SELECT?

iain_r
07-22-2015, 03:53 AM
@version 2.8
@warnings
@script generic


generic
{
EditCameras();
ItemProperties();
}

Regards

Iain

spherical
07-22-2015, 04:24 PM
SWEET! Thanks, Iain. Works a treat. :) I owe you a pint.

Which leads me to ponder: That few lines of code and it's a big problem for this function to be integrated into the application itself as default?

iain_r
07-23-2015, 02:27 AM
I would think that it's most likely to be historical, in that they assume you would load an object before considering opening the properties panel. There's lots of little things like this that could be looked at, it just depends on how much time they have to go through all the code and fix these things. There are lots of panels and commands that I would like to be able to access via scripts but they're not available. Big pain is some panels will accept parameters and others will not. Anyway getting off topic.

glad it worked, Iain.

spherical
07-23-2015, 04:48 AM
Yep. I deployed it to all of my many version installs. Will do the same on my partner's machine, as it's one less thing to break one's concentration when sitting down to do creative work.

MrFurious
07-26-2015, 03:22 PM
Thanks Guys it's helped get me started but this is a completely new language for me so.. I can manage to build something basic with the LS commander its all the other syntax I don't know. Iain your script is great but form some reason the scene editor doesn't appear to open but it's there in the master plugin window..weird. I suppose it's not a big deal the presets window can't detect the current state, as it would always be closed by default on startup. I was thinking with the Object and Motion panels, maybe a workaround could be to have the script (in this order) add a null, open the object properties, delete the null, select the camera, open the motion options panel.? do you think that might work?

MrFurious
07-26-2015, 03:35 PM
I added the octane part myself, yay!

MrFurious
07-26-2015, 03:55 PM
This opens the opject properties and motion options panels, but you have to confirm removal of the null



@version 2.8
@warnings
@script generic
@name "Start2"
generic
{
ApplyServer("MasterHandler", ".SceneEditorStandardBanks");
ApplyServer("MasterHandler", "SceneEditor");
EditServer("MasterHandler", 4);
CommandInput("GraphEditor 1");
CommandInput("SurfaceEditor 1");
CommandInput("ImageEditor 1");
Presets();
AddNull("Null");
ItemProperties();
ClearSelected();
EditCameras();
MotionOptions();
}

MrFurious
07-26-2015, 04:10 PM
Or this which leaves behind the null which can be recycled or deleted later.


@version 2.8
@warnings
@script generic
@name "Start2"
generic
{
ApplyServer("MasterHandler", ".SceneEditorStandardBanks");
ApplyServer("MasterHandler", "SceneEditor");
EditServer("MasterHandler", 4);
CommandInput("GraphEditor 1");
CommandInput("SurfaceEditor 1");
CommandInput("ImageEditor 1");
Presets();
AddNull("Delete Me");
ItemProperties();
EditCameras();
MotionOptions();
}

MrFurious
07-26-2015, 04:21 PM
Is it possible to force a keystroke in Lscript?

erikals
07-26-2015, 05:22 PM
not in lscript i believe, maybe with python, but kind of doubt it... akh can do it, if you wanna go the ahk route

MrFurious
07-26-2015, 07:11 PM
I was thinking about trying AHK but I what I have with Lscript works pretty well but I'm having real trouble with the StartupCommand in the LW config. it keeps disappearing and wont execute on launch has anyone had success with this?

ernpchan
07-26-2015, 07:45 PM
I've done start up scripts via master plugin scripts. Is that how you're doing it?

MrFurious
07-26-2015, 08:02 PM
I don't think so then again im not sure what a master script is. Is it anything like a master plugin? I was following another thread which suggested adding 'StartupCommand Generic_scriptname' to the Layout config file.

oliverhotz
07-26-2015, 08:12 PM
you could do an AutoConfirm 1 and Autoconfirm 0 command... (for the deletion of the null)

MrFurious
07-26-2015, 08:33 PM
you could do an AutoConfirm 1 and Autoconfirm 0 command... (for the deletion of the null)

Perfect.. how would that command look in Lscript? I did a keyword search on Autoconfirm in the Lscript user manual but it's not there

MrFurious
07-26-2015, 08:44 PM
you could do an AutoConfirm 1 and Autoconfirm 0 command... (for the deletion of the null)

All good, I found it in another thread.. works like a charm!! worked out you have to place the autoconfirm BEFORE the clear command. Here's what we have so far it's almost complete!, except I still can't get the scene editor to open.


@version 2.8
@warnings
@script generic
@name "StartupScript"
generic
{
ApplyServer("MasterHandler", ".SceneEditorStandardBanks");
ApplyServer("MasterHandler", "SceneEditor");
EditServer("MasterHandler", 4);
CommandInput("GraphEditor 1");
CommandInput("SurfaceEditor 1");
CommandInput("ImageEditor 1");
Presets();
AddNull("Delete Me");
ItemProperties();
AutoConfirm(1);
ClearSelected();
EditCameras();
MotionOptions();
}

iain_r
07-27-2015, 04:55 AM
What version of Lightwave are you using, I created the basic script for 11.6.3 and it works okay in that. Which scene editor are you trying to load. I've also tried having the script included as the first line in the config file and not had any issues, everything loaded as I wanted.

Regards

Iain

MrFurious
07-27-2015, 05:05 AM
11.6.3 here also and I use the newer Scene/Dope editor, CTRL-F1 to open. Could you tell me how you setup your config file? I can't get it to autostart on LW launch

update- Scene editor works now after clearing a few master plugins. It seems if there is a 3rd item in the master plugins list this script won't open the scene editor. I guess I'd have to change the number 4 in this line "EditServer("MasterHandler", 4);" depending on how many master plugins are in the list?

iain_r
07-27-2015, 06:15 AM
The first part is to load the plugin i.e. Utilitie tab, add plugin. This will tell layout that the plugin exists, it updates the LWEXT11-64.CFG file. The file LW11-64.CFG has as its first line "StartupCommand Generic_StartupScript" without the quotes. The @name parameter in the script is used here, which is why I normally include one when creating a script.

The masterhandler value will depend on what you have loaded, I only have the defaults so in ls commander it put the number 4 as the parameter. It would depend on what number of master plugins you have loaded.

Regards

Iain

MrFurious
07-27-2015, 12:33 PM
That's the strange part.. "StartupCommand Generic_StartupScript" is nowhere to be found in my LW11-64.CFG, and if I add this to the first line of my config then launch LW and close, the startup line is removed from LW11-64.CFG

spherical
07-27-2015, 01:31 PM
That's the strange part.. "StartupCommand Generic_StartupScript" is nowhere to be found in my LW11-64.CFG, and if I add this to the first line of my config then launch LW and close, the startup line is removed from LW11-64.CFG

Is that the exact line you are pasting in? It needs to be:
StartupCommand Generic_[whatever-the-filename-of-the-script-is-without-the extension]

So, if the filename is starteverything.ls, the line would be:
StartupCommand Generic_starteverything

The file also needs to be in the plugins directory tree somewhere for LW to find it. Mine are in:
/support/plugins/scripts/LScript/3rd
as I keep all non-LW plugins and scripts in dedicated folder trees under both of the default locations.

MrFurious
07-27-2015, 02:44 PM
Thanks Iain & Spherical. I got it to work and I was doing everything right but what eventually got it to work was placing the line "StartupCommand Generic_scriptname" not in the first line of the config file. No idea why this is as every thread I've read says to place it in the first line. I also learned the autoconfirm command is persistent and needs to be turned off.

Here's the finished script if anyone wants to try it:


@version 2.8
@warnings
@script generic
@name "startupscript"
generic
{
ApplyServer("MasterHandler", ".SceneEditorStandardBanks");
ApplyServer("MasterHandler", "SceneEditor");
//the number following the masterhandler should be the number of masterplugins loaded plus 2
//in this case I have 4 masterplugins loaded at LW launch so masterhandler id is 6
EditServer("MasterHandler", 6);
CommandInput("GraphEditor 1");
CommandInput("SurfaceEditor 1");
CommandInput("ImageEditor 1");
Presets();
AddNull("Delete Me");
ItemProperties();
AutoConfirm(1);
ClearSelected();
AutoConfirm(0);
EditCameras();
MotionOptions();
}

If you use Octane and would also like to have it automatically Authenticate and open IPR (paused) and the Render Target Panel try this:


@version 2.8
@warnings
@script generic
@name "startupscript"
generic
{
ApplyServer("MasterHandler", "Octane_MASTER_PLUGIN");
CommandInput("Generic_Octane_Enable");
ApplyServer("MasterHandler", ".SceneEditorStandardBanks");
ApplyServer("MasterHandler", "SceneEditor");
//the number following the masterhandler should be the number of masterplugins loaded plus 2
//in this case I have 4 masterplugins loaded at LW launch so masterhandler id is 6
EditServer("MasterHandler", 6);
CommandInput("GraphEditor 1");
CommandInput("SurfaceEditor 1");
CommandInput("ImageEditor 1");
Presets();
AddNull("Delete Me");
ItemProperties();
AutoConfirm(1);
ClearSelected();
AutoConfirm(0);
EditCameras();
MotionOptions();
CommandInput("Generic_Octane_NodalRenderTarget 1");
CommandInput("Generic_Octane_ActivateIPR 1");
CommandInput("Generic_Octane_IPR_Pause");
}

Many thanks for all the help.

spherical
07-27-2015, 05:44 PM
I put it in the first line and when the config gets stored at application close, it gets moved a couple of lines down but is intact.