PDA

View Full Version : Is there one script to control the obj Visibility in layout??



xueqing12
09-14-2007, 08:59 PM
This is my script, but i can't jump out the if! Please help me!!


@warnings
@name Vis_Switch

generic
{

if(ItemVisibility != 7)
{
ItemVisibility(7);
return;
}

if(ItemVisibility != 1)
{
ItemVisibility(1);
return;
}


}

GregMalick
09-14-2007, 11:01 PM
I think you are saying that the second if is never executed.
That's because you have a return in there. Ends the program.

Here's one that turns all selected it's visible.
It should help:


@version 2.6
@warnings
@script generic
@name showHidden

generic {
scene = Scene();
selectedItems = scene.getSelect();
if (selectedItems.size() < 1) return;

SelectItem(selectedItems[1].name);
ItemVisibility(1);
for (i=2; i<= selectedItems.size(); ++i) {
AddToSelection(selectedItems[i].name);
ItemVisibility(1);
}
}

xueqing12
09-15-2007, 03:12 AM
Thanks, GregMalick.
But I still can't get the switch to the obj Visibility.
I don't know how to use your help!!
Sorry!!

LightFreeze
09-15-2007, 06:11 AM
ItemVisibility is write only, you cannot get a value from it




@warnings
@name Vis_Switch

generic
{
debug();

x = ItemVisibility;
if(ItemVisibility != 7)
{
ItemVisibility(7);
return;
}

if(ItemVisibility != 1)
{
ItemVisibility(1);
return;
}


}

xueqing12
09-15-2007, 12:44 PM
Thanks, LightFreeze!!
Cannot get a value from it ItemVisibility!!!

So, is there other way to switch the Visibility!!???

evenflcw
09-15-2007, 02:46 PM
You can get the currently set visibility value from each items object agent. Check page 98 in the Lscript Reference manual (Common Data Members and Methods-chapter).

This is often the case. You read the current value from the oa(s). Then to change them you select the item(s) and execute the function that alters the value.

GregMalick
09-15-2007, 09:39 PM
in other words:


if (selectedItems[i].visibilty != 1)
ItemVisibility(1);

I'm getting rusty with LScript since I switched to writing plugins... :D