I'm writing a script for After Effects that collects all properties from a layer and write them into an XML file. When I retrieve the values from the XML, some values are readOnly and the toolkit throws an error.
Is there any way to check it, like readonly attribute of File object? ie: layer.property().(readonly||readOnly)
If not, someone can tell me wich aproach can I take to go in the right direction?
Given that the first item in the project is a comp with a solid in it, this works but it is arguably kludgey, and you'd need to be able to build the (each) string in order to do this -- but maybe you are already set up to do that:
var r;
r = testForReadability("app.project.items[1].layers[1].enabled");
alert(r);
r = testForReadability("app.project.items[1].layers[1].width");//a solid's width is NOT writable
alert(r);
function testForReadability(thisProperty) {
var x;
try {
x = eval(thisProperty);
eval(thisProperty + " = x;");
return true;
} catch(e) {
return false;
}
}
However, there is a small can of worms opening up here, in that "false"s will not work if the "Enable Script Debugger" option is set. So you need to do a workaround in order to check for this setting and temporarily reset it (see http://aenhancers.com/viewtopic.php?f=8&t=189&p=554&hilit=debugger#p554 )
I don't think you can get this information from the ESTK.
You can use the 'After Effects Scripting Guide Book' to check and create an object that contains all the 'readonly' properties, and then to check if the object includes this property.
Here's a link for the scripting guide: After-Effects-CS6-Scripting-Guide
Just try to override it, and revert it back, like this:
function isReadOnly(value, container) {
var tmp = container[value];
var tmp2;
var coolString = "cool";
try {
container[value] = "cool";
} catch (e) {
return true
}
tmp2 = container[value];
container[value] = tmp;
return coolString != tmp2;
}
// true, navigator.platform is read only
console.log(isReadOnly("platform", navigator))
// false, window.parent is not read only
console.log(isReadOnly("parent", window))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With