-
Select property only in certain property groups
Dear Creative Cow People,
i’m currently struggling to find a good solution for a little script i’m working on – it currently selects all color properties in the selected layer. I want to refine this script by only selecting the color property, if it is within a property group called “Stroke” (for example).
I tried using “propGroup.name === ‘Stroke’ ” in the if condition, but it doesn’t seem to work – and furthermore, sometimes a shape layer will have several “Stroke” groups or ones that have numbers appended, such as “Stroke 1” or similar.
What would be the best way to approach this?
Thanks in advance – any help is greatly appreciated!
Kind regards
Florian
{
app.beginUndoGroup("Set Colors");var myComp = app.project.activeItem;
var numLayer = myComp.selectedLayers;
var colorExp = '(placeholder for color expression)';if (numLayer.length == 0) {
alert("NO LAYERS SELECTED - Please select one or several Layers before running this script.", "Color");} else {
function scanPropGroupProperties(propGroup) {
var i, prop;// Iterate over the specified property group's properties
for (i = 1; i <= propGroup.numProperties; i++) {
prop = propGroup.property(i);
if (prop.propertyType === PropertyType.PROPERTY && prop.name === 'Color' && propGroup.canSetEnabled) // Found a property
{
prop.expression = colorExp
} else if ((prop.propertyType === PropertyType.INDEXED_GROUP) || (prop.propertyType === PropertyType.NAMED_GROUP)) {
// Found an indexed or named group, so check its nested properties
scanPropGroupProperties(prop);
}
}
}for (var i = 0; i < numLayer.length; i++) {
scanPropGroupProperties(numLayer[i]);
}}
app.endUndoGroup();
}