PDA

View Full Version : Loading Scenes and Expressions with LScript



rtl114
08-01-2011, 05:59 AM
I know you can load items from a scene using "LoadFromScene", but can you restrict what gets loaded from that scene? For instants I do not want the lights. Can anyone point me in the right direction? Also, is there a way to load an expression file with LScript (and assign them to the correct bone too)? Thanks for any help.

Ross

rtl114
08-03-2011, 05:36 AM
So, I'm guessin' the answer is "no".....

nikfaulkner
08-03-2011, 08:51 AM
i think its a "no" although there was some way to parse scene data (including expressions) into a scene with lscript. i found it on here somewhere a couple of years back.

rtl114
08-04-2011, 08:23 AM
Thanks, I found some of what I need!

Blochi
08-07-2011, 12:59 PM
LoadFromScene is a tricky one, it doesn't always behave in a script. There is another sibling, though:



@version 2.7
@warnings

generic
{
AutoConfirm(true);
CommandInput("LoadElementsFromScene 4 E:\\myPath\\myScene.lws");
AutoConfirm(false);
}


But for the longest time you couldn't actually suppress the user dialog where the user can actually choose things, which makes the entire method somewhat flawed. That's what the AutoConfirm is supposed to be for, not sure if this is still ignored in this context.

The general safe method instead is to write the current scene to disk with "SaveSceneCopy", re-open it as file object, hack it, and load the full thing.

But for expressions you don't really need that. Here is a little Master script example I found, can't remember where, that attaches an expression to the selected object. The critical parts are CreateExpression() and AttachExpression().



@version 2.2
@warnings
@script master
@name Expression Test

/*
Hello,

If you run attached script you may get that expression
thing working... It's a master class script. Run it
and press 'Add expression' button. Then expression
would be created and attached to the Camera Position X
envelope...

regards
Darren
*/


script_name = "Expression Test";

exp_name = "test";
exp = "[Light.Position.X]/2";
exp_exp;

c0..10;

create
{
setdesc(script_name);
}

destroy
{
if (reqisopen())
{
reqend();
}
}

flags
{
return(SCENE);
}

process: event, command
{
}

load: what,io
{
if(what == SCENEMODE) // processing an ASCII scene file
{
}
}

save: what,io
{
if(what == SCENEMODE)
{
}
}

options
{
reqbegin(script_name);

c2 = ctlbutton("Add Expression",130,"add_exp");
reqopen();
}

add_exp
{
com = string("GE_CreateExpression ",exp_name," ",exp);
CommandInput(com);

com = string("GE_AttachExpression ","Camera.Position.X"," ",exp_name);
CommandInput(com);
}

dblincoe
08-07-2011, 02:03 PM
You do know you can exclude the lights and the camera when using "load from scene". If the check mark besides it is greyed out it won't import, if it is highlighted then it will. You can select any object, light or camera.

Of course, you may be after another way. I just thought I'd make sure you knew that so you were't chasing something you already had.

Blochi
08-07-2011, 02:39 PM
Yes, of course. I was strictly talking about automating this Load From Scene selection process in the context of a larger script. If the script is a batch process or does additional setup steps with the loaded items, it may be necessary to bypass user interaction.

It gets a hell of a confusing when an "AutoSetup Insanely Awesome Character Rig" script comes with instructions to "Please set a checkmark for all Bone Items on the LoadFromScene dialog that pops up half-way through the setup process, and make sure to uncheck the Camera otherwise this script may overwrite your current Camera animation."

dblincoe
08-07-2011, 02:54 PM
Yes, of course. I was strictly talking about automating this Load From Scene selection process in the context of a larger script. If the script is a batch process or does additional setup steps with the loaded items, it may be necessary to bypass user interaction.

It gets a hell of a confusing when an "AutoSetup Insanely Awesome Character Rig" script comes with instructions to "Please set a checkmark for all Bone Items on the LoadFromScene dialog that pops up half-way through the setup process, and make sure to uncheck the Camera otherwise this script may overwrite your current Camera animation."

Gotcha.

Dodgy
08-07-2011, 06:09 PM
You could go through the lights before load from scene and see how many there are, then laod from scene and clear out any extra lights....

rtl114
08-08-2011, 06:54 AM
Thanks for the info everyone...

rtl114
08-15-2011, 08:33 AM
Is there a way to make LoadFromScene import the Master Plugins by default? So, I can still use AutoConfirm(false) and I will get ther master plugins.

Thanks,
Ross

dblincoe
08-15-2011, 08:39 AM
Regarding the lights...I've also renamed the original scene lights something like "delete me" or "kill" then in the new scene used the object filter to search for that prefix on the lights and deleted them.