View Full Version : Multiple object lyrswap() problem

10-22-2011, 06:57 PM
I've run into an LScript issue that's got me stumped. (Not that that's really difficult or anything.)
First this is in LW 9.6.1, there's no money in the budget for upgrading to LW10 at the moment.

Create or load 3 or 4 objects in Modeler, Multi-select a bunch of Foreground & background layers in all of
these objects. For this example it isn't necessary to have data in any of the layers but it does help with
visually demonstrating the issue. Without data, watch the "Layers" window see what's going on.

Now do a View>Layers>Swap Layer (The default hotkey for this is ' )

Everything functions as expected, the FG layers become the BG layers, the BG layers become the FG layers.

Now try running this LScript and watch what happens

@script modeler


fg = lyrfg();

bg = lyrbg();


The layer swap is attempted in only one object and very obviously not what's wanted.

Setup the layer selection again and this time run the LScript with the debug() function uncommented.

As you step through the script in the debug window stop at the lyrswap() function and examine the
contents of the fg and bg arrays and you'll see what the problem is. The layers in these arrays
are not being given unique identifiers.

The ID for the first object's layer 1, is exactly the same as the ID for second and third object's
layer 1's, and it's the same with layer 2's, 3's, and so on.

What's frustrating is that Modeler assigns each object a unique ID so it does indeed
know the difference between object 1's layer 1 and object 2's layer 1. LScript just isn't using
that info with functions like lyrswap() and lyrfg().

I was hoping that invoking a Mesh() object agent (Which can access the an objects unique ID) would
automagically fix things, but it definitely doesn't do that, and so far I haven't found a way to
use the Mesh object's abilities to resolve this issue.

Hopefully I'm just being dense and missing something.

Tested on both winXP 32-bit & win7 64-bit