// Isosceles_RemoveExpressions.jsx
// Code generated by ChatGPT-4o
// Date: May 23, 2025
// Description: This After Effects script will remove all expressions from the selected comps in the Project window.

// Remove expressions from only selected layers in the active composition
(function removeExpressionsFromSelectedLayers() {
    var comp = app.project.activeItem;

    if (!(comp instanceof CompItem)) {
        alert("Please select a composition.");
        return;
    }

    var selectedLayers = comp.selectedLayers;

    if (selectedLayers.length === 0) {
        alert("Please select at least one layer.");
        return;
    }

    app.beginUndoGroup("Remove Expressions from Selected Layers");

    for (var i = 0; i < selectedLayers.length; i++) {
        var layer = selectedLayers[i];

        // Loop through all properties in the layer
        removeExpressionsRecursively(layer);
    }

    app.endUndoGroup();

    function removeExpressionsRecursively(group) {
        var numProps = group.numProperties;

        for (var i = 1; i <= numProps; i++) {
            var prop = group.property(i);

            if (prop.canSetExpression && prop.expressionEnabled) {
                prop.expression = ""; // Remove the expression
                prop.expressionEnabled = false;
            }

            // If it's a group (like Transform), recurse
            if (prop.propertyType === PropertyType.PROPERTY_GROUP || prop.propertyType === PropertyType.NAMED_GROUP) {
                removeExpressionsRecursively(prop);
            }
        }
    }
})();
