-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EF_MakePropertiesValidAgain.jsx
57 lines (47 loc) · 2.13 KB
/
EF_MakePropertiesValidAgain.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**========================================================================
* ? EF_MakePropertiesValidAgain.jsx
* @author Eveline Falcão <https://evelinefalcao.com>
* @email [email protected]
* @version 1.0.0
* @createdFor Adobe After Effects CC 2024 (Version 24.1.0 Build 78)
* @description Create a reference object for the selected properties, allowing you to locate them after they become invalid due to added or removed effects.
*========================================================================**/
(function makePropertiesValidAgain() {
var comp = app.project.activeItem;
var selectedProps = comp.selectedProperties;
if (selectedProps.length > 0) {
// Make property references
var propsToProcess = [];
for (var i = 0; i < selectedProps.length; i++) {
var currentProp = selectedProps[i];
var reference = createNestedPropertyReference(currentProp);
propsToProcess.push(reference);
}
// Get property from references
for (var i = 0; i < propsToProcess.length; i++) {
var reference = propsToProcess[i];
var prop = getNestedPropertyFromReference(reference);
// Do something to the property
alert(prop.name);
}
}
function createNestedPropertyReference(property) {
var layer = property.propertyGroup(property.propertyDepth);
var propIndices = [];
for (var depth = property.propertyDepth; depth > 0; depth--) {
propIndices.unshift(property.propertyIndex);
property = property.propertyGroup();
}
// Save layer and indices
return { layer: layer, propIndices: propIndices };
}
function getNestedPropertyFromReference(propertyReference) {
var layer = propertyReference.layer;
var propIndices = propertyReference.propIndices;
var prop = layer;
for (var j = 0; j < propIndices.length; j++) {
prop = prop.property(propIndices[j]);
}
return prop;
}
})();