PDA

View Full Version : script or plugin: hide Camera(s) and Light(s) / tales of woe



jeric_synergy
09-25-2014, 02:16 AM
OK, searched NTek Plugins, googled "lightwave hide camera", searched my own archives.....

I know somebody wrote a little script that would simply hide the camera and light (and hopefully all of them). Anyone know what/where that

I think I could simply snag the LScript out of LScommander for the 1st camera and the 1st light, but not sure what to do about subsequent lights-- just ignore errors?

::SIGH::

OK, now here's my tale, so that perhaps someone somewhere can reduce a poor LW users confusion, and to communicate how confusion ensues:

I decided to emulate Chazriker and use LSCommander (LSC) to create this simple script. Using an LWS with >4 lights, I selected and hid the camera and 2 lights. Used LSC's INSTALL function to add this macro, I added it to the config. It worked fine with this script.

Here's the code LSC generated:

@warnings
@name Hide_Cam+Lights.ls

generic
{
SelectItem("Camera");
ItemVisibility(0);
SelectItem("Light (1)");
ItemVisibility(0);
SelectItem("Light (2)");
ItemVisibility(0);
}

Quit and Relaunched. With a default scene, ran the script. Now I get an error, but not on the 'missing' lights, but line7: " ItemVisibility(0);" which should be addressing the Camera
The error, and btw it'd be fracking convenient if we could C&P the damn error text rather than retyping it, is
"Line 7, invalid argument 1 value to ItemVisibility()"

Not sure if this is argument #1 or the value 1, since the value is obviously zero.

Other bugs encountered but not repeated are values of "-1" rather than zero when reloading an LScript to a 'session', and truncation of item id#s. And a script that works fine, but only once.

Constantly encountering these roadblocks is very frustrating.

Sensei
09-25-2014, 11:08 AM
I have the same while trying your example.

That's why I am not touching LScript ;)

You should forget about it, and switch to C/C++.

I think so using CommandInput("ItemVisibility 0") instead should allow using ItemVisibility command..

ernpchan
09-25-2014, 11:41 AM
Probably better to iterate through the lights and cameras, select them and then run the hide command. That may not fix your argument problem but it'd be a cleaner way of doing what you want.

I thought RebelHill made a script to do exactly this.

jeric_synergy
09-25-2014, 11:59 AM
Somebody did, but i don't think it was RH-- my vague recollection was it was one of the Aussie crew.

Anyway, it's a good exercise, except for the fact that the native tools are broken. For instance, converting a LScript to a LSC 'session' will result in a non-valid parameter, -1, being applied to ItemVisibility(). AFAICT, -1 doesn't even have a meaning. Between the bugs and the documentation, I'm not encouraged.

In lesser but still aggravating aspects: apparently ItemVisibility() doesn't START at zero, like a great many computer-ish things, but at 1, with 1=Hidden. Why someone would design it this way, don't ask me. Perhaps 0=toggle.

Sensei's advice is probably good: fighting with LScript's many shortcomings (ha! that's me being polite) is probably a greater hassle than learning C/C++.

Sensei
09-25-2014, 12:14 PM
Values for ItemVisibility are described in LWSDK/include/lwrender.h
Yes, 0 is valid value for it.
Execute command, like I said.
You can always experiment in Layout, there is Command Input in Utilities and enter/copy it.

jeric_synergy
09-25-2014, 01:26 PM
as I already typed, I plucked all the commands directly from LSCommndr. The resulting macro worked ONCE, and on relaunches did not. Converting between LS and CS introduced a value of -1 into the ItemVisibility() function.

Who the hell has time to debug all this caca? All I do is find bugs, but I'm no longer a beta tester.

erikals
09-25-2014, 02:39 PM
maybe some code in ef_itemvisibilitytoggle could help

http://people.dsv.su.se/~dadu9329/evenflow3d/index.php

iain_r
09-25-2014, 02:49 PM
This should hide all the cameras and lights in the scene. I've closed layout and reloaded and didn't get an error. Trying this in 9.6.

Regards

Iain


@version 2.8
@warnings
@name HideCamLights
@script generic

// Hides all cameras and lights in the scene
//Set Global Variables
frame = 1;

generic
{
scene = Scene();
SelectAllLights();
selItems = scene.getSelect();
for(i = 1; i <= selItems.size(); i++){
SelectItem(selItems[i].name);
CommandInput("ItemVisibility 0");
}

SelectAllCameras();
camItems = scene.getSelect();
for(i = 1; i <= camItems.size(); i++){
SelectItem(camItems[i].name);
CommandInput("ItemVisibility 0");
}
}

jeric_synergy
09-25-2014, 04:03 PM
Thanks fellas, I'll give that a whirl. I'm sure that will work. (EDIT: seems to work fine: THANKS! Added to DISPLAY tab.)

However, the post is not so much about the actual functionality (which I'm very excited about-- working is easier when you can reduce the clutter in the scene), but the bugs I found (Why does it work ONCE? Why does LS>CS introduce errors?) and just the general difficulty I had.

Maybe I'm a moron, but I'm pretty sure I'm at least as capable as other customers. They say for every customer who actually speaks up, there's ~7 who had the same problem and just gave up on a feature. I'm a very loud & whinging canary in a coal mine, finding all these loose ends that should be cleaned up.

erikals
09-25-2014, 04:04 PM
Beautiful..!

just made it ShowCamLights by changing two zeros...

...makes me "coder of the year!" http://erikalstad.com/backup/misc.php_files/smile.gif


@version 2.8
@warnings
@name ShowCamLights
@script generic

// Hides all cameras and lights in the scene
//Set Global Variables
frame = 1;

generic
{
scene = Scene();
SelectAllLights();
selItems = scene.getSelect();
for(i = 1; i <= selItems.size(); i++){
SelectItem(selItems[i].name);
CommandInput("ItemVisibility 1");
}

SelectAllCameras();
camItems = scene.getSelect();
for(i = 1; i <= camItems.size(); i++){
SelectItem(camItems[i].name);
CommandInput("ItemVisibility 1");
}
}

erikals
09-25-2014, 04:15 PM
https://www.youtube.com/watch?v=GObOMXrLA_k

jeric_synergy
09-25-2014, 04:19 PM
Beautiful..!

just made it ShowCamLights by changing two zeros...
Good idea!

RebelHill
09-25-2014, 05:40 PM
I thought RebelHill made a script to do exactly this.

Animation Toolbox.

erikals
09-25-2014, 08:49 PM
http://forums.newtek.com/images/misc/quote_icon.pngRebelHill
Animation Toolbox

available in the free version of RHiggit >
http://www.rebelhill.net/html/rhiggit.html

https://www.youtube.com/watch?v=7LxtV07BEl0

iain_r
09-27-2014, 04:01 AM
Quick update, I've made it select the first mesh after hiding the camera so that it drops the camera selection and it doesn't appear as if the script has not made the camera invisible as seen in the example of Erikals video.

Regards

Iain


@version 2.8
@warnings
@name HideCamLights
@script generic
//Set Global Variables
frame = 1;

generic
{
scene = Scene();
SelectAllLights();
selItems = scene.getSelect();
for(i = 1; i <= selItems.size(); i++){
SelectItem(selItems[i].name);
CommandInput("ItemVisibility 0");
}

SelectAllCameras();
camItems = scene.getSelect();
for(i = 1; i <= camItems.size(); i++){
SelectItem(camItems[i].name);
CommandInput("ItemVisibility 0");
}

obj = Mesh();
obj.select();
}

erikals
09-27-2014, 09:12 AM
nice, would it be easy to make it select the last obj selected before the script has ran ?

jeric_synergy
09-27-2014, 09:24 AM
nice, would it be easy to make it select the last obj selected before the script has ran ?
I'd be surprised: the Camera or a Light could have been selected.

I don't think Layout has any sort of "selection history" to use in this case. --I could be wrong.

Sensei
09-27-2014, 09:30 AM
In many Layout commands that I wrote, I am recording current items selection, then doing task, then restoring previous items selection.
Requires making 2nd-ary list of items, though.

jeric_synergy
09-27-2014, 09:52 AM
d'oh: just switching to Object Mode will reveal the last Object selected.

erikals
09-27-2014, 07:30 PM
nope, not here...

jeric_synergy
09-27-2014, 08:38 PM
? Well, what object DOES it reveal?

erikals
09-28-2014, 07:26 AM
seems to select the first object...

RebelHill
09-28-2014, 10:23 AM
If you use...

item=Mesh();
item.select();

It selects the first object.

If you just use...

EditObjects();

It switches to the last selected object.

jeric_synergy
09-28-2014, 10:37 AM
H! I 'knew' it!!! (for certain values of 'knew')