for some reason I cannot get the index of the selected layer. having a brain fart.
trying to turn off visibility of selected layer then turn on visibility next layer and have next layer also be active layer.
Code: Select allvar currentLayer = app.activeDocument.activeLayer.length;
var activelayer = app.activeDocument.activeLayer;
activelayer.visible = false;
var nextLayer = currentLayer-1;
nextLayer.visible = true;
app.activeDocument.activeLayer = nextLayer;
get index of selected layer
get index of selected layer
Bonjour lukasz
I think this corresponds to what you seek :
Code: Select allvar doc = app.activeDocument;
var currentLayer = doc.activeLayer;
for(i=0; i < doc.layers.length; )
{
if(doc.layers==currentLayer)
{
a=i;
//alert(a);
i = doc.layers.length;
}
else{ i++; }
}
currentLayer.visible = false;
try
{
var nextLayer = doc.layers[a-1];
}
catch(e)
{
var nextLayer = doc.layers[doc.layers.length-1];
}
nextLayer.visible = true;
doc.activeLayer = nextLayer;
I think this corresponds to what you seek :
Code: Select allvar doc = app.activeDocument;
var currentLayer = doc.activeLayer;
for(i=0; i < doc.layers.length; )
{
if(doc.layers==currentLayer)
{
a=i;
//alert(a);
i = doc.layers.length;
}
else{ i++; }
}
currentLayer.visible = false;
try
{
var nextLayer = doc.layers[a-1];
}
catch(e)
{
var nextLayer = doc.layers[doc.layers.length-1];
}
nextLayer.visible = true;
doc.activeLayer = nextLayer;
get index of selected layer
that worked perfect. one more issue though.
documentation says index is method of layers, but I can't seem to select via the index. any idea whats going on?
Code: Select allvar newActivelayer = doc.layers.index(1);
documentation says index is method of layers, but I can't seem to select via the index. any idea whats going on?
Code: Select allvar newActivelayer = doc.layers.index(1);
get index of selected layer
Not like that…
Code: Select allapp.activeDocument.activeLayer = app.activeDocument.layers[1];
Index inside of a square bracket pair…
Code: Select allapp.activeDocument.activeLayer = app.activeDocument.layers[1];
Index inside of a square bracket pair…
get index of selected layer
still a little hiccup. doesnt seem to want to select next layer, however it does make it visible? which seems weird because it makes it visible after it selects the layer in the code, or should? but in the document the next layer is not selected.
Code: Select all#target illustrator
var activelayer = app.activeDocument.activeLayer;
activelayer.visible = false;
for(i=0; i < doc.layers.length; )
{
if(doc.layers==activelayer)
{
var a = i;
alert(a);
var i = doc.layers.length;
var b = a+1;
}
else{ i++; }
}
app.activeDocument.activeLayer = app.activeDocument.layers;
var activelayer = app.activeDocument.activeLayer;
activelayer.visible = true;
Code: Select all#target illustrator
var activelayer = app.activeDocument.activeLayer;
activelayer.visible = false;
for(i=0; i < doc.layers.length; )
{
if(doc.layers==activelayer)
{
var a = i;
alert(a);
var i = doc.layers.length;
var b = a+1;
}
else{ i++; }
}
app.activeDocument.activeLayer = app.activeDocument.layers;
var activelayer = app.activeDocument.activeLayer;
activelayer.visible = true;
get index of selected layer
#target illustrator
Sorry but you can't expect the syntax of Photoshop to work with Illustrator… While there are common objects like app & doc little else will work… In PS layers can exist inside a doc or layer set… In Illustrator they can exist anywhere… other layers, groups, etc… this needs to be scripted as per the Illustrator DOM…
Sorry but you can't expect the syntax of Photoshop to work with Illustrator… While there are common objects like app & doc little else will work… In PS layers can exist inside a doc or layer set… In Illustrator they can exist anywhere… other layers, groups, etc… this needs to be scripted as per the Illustrator DOM…
get index of selected layer
hmmm, interesting. I understand not all of it will work. but usually the core dom is the same, they do handle layers differently though. i will look into that.
get index of selected layer
lukasz wrote:but usually the core dom is the same
It has been my experience that the core javascript is the same, but the DOM's for each Adobe app have little if anything in common.
It has been my experience that the core javascript is the same, but the DOM's for each Adobe app have little if anything in common.
get index of selected layer
Try getting the name of your active layer… You will see it's the one you wanted it's just a lazy UI that does not redraw as you would expect… Even app.redraw() will not refresh this for you…