how to check whether a selected layer is a nullLayer?

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
User avatar
Chason_X
Posts: 2
Joined: July 25th, 2018, 9:50 pm

Sorry my Mother tongue wasn't English,so my English wasn't good enough.
I wanted to write a script which need a feature that check whether a selected layer is a null Layer,therefore I try to write a simple script to test,but it didn't work.
this is my test script:

var myComp = app.project.activeItem;
var Selected = myComp.selectedLayers;

if (Selected[0] instanceof nullLayer)
{
alert ("a")
}
else
{
alert( "!");
}


who can help me? thanks!
User avatar
zlovatt
Posts: 47
Joined: October 31st, 2016, 5:00 pm
Location: Portland
Contact:

The check for null layer is just layer.nullLayer, not layer instanceof nullLayer

Code: Select all

(function () {
  var comp = app.project.activeItem;
  var layer = comp.selectedLayers[0];

  if (layer.nullLayer) {
    alert('Layer is a null')
  } else {
    alert('Layer is not a null');
  }
})();
See: http://docs.aenhancers.com/layers/layer ... -nulllayer
User avatar
Chason_X
Posts: 2
Joined: July 25th, 2018, 9:50 pm

zlovatt wrote: July 26th, 2018, 12:08 pm The check for null layer is just layer.nullLayer, not layer instanceof nullLayer

Code: Select all

(function () {
  var comp = app.project.activeItem;
  var layer = comp.selectedLayers[0];

  if (layer.nullLayer) {
    alert('Layer is a null')
  } else {
    alert('Layer is not a null');
  }
})();
See: http://docs.aenhancers.com/layers/layer ... -nulllayer
Thanks for your help,it have worked! Thank you very much!
Post Reply