Copy link to clipboard
Copied
I've got an object that stores references to comps and layers, and I am trying to validate the object before attempting to access those objects. How can I test whether these comps and layers are valid (i.e. have not been deleted)? Even after they have been deleted they still register as objects, so conventional tests for the object's existence don't work, but any attempt to access them throws an "Object is invalid" error, so I can't test the object's structure for validity.
There's a method for that: isValid(obj);
https://ae-scripting.docsforadobe.dev/general/globals/#isvalid
Copy link to clipboard
Copied
Have you tryed to use a try/catch statement?
Copy link to clipboard
Copied
I experimented with it a bit, but I'm not quite sure how to construct a function to which I can pass a potentially invalid object to test. The script simply stops execution when I try to do so.
Copy link to clipboard
Copied
There's a method for that: isValid(obj);
https://ae-scripting.docsforadobe.dev/general/globals/#isvalid
Copy link to clipboard
Copied
Fantastic. I'm not sure how I missed it when searching the docs, but this is a lifesaver.