Forum Replies Created

  • Shane Shornock

    October 25, 2023 at 5:36 pm in reply to: Using a layer as a boundary for other layers

    if (app.project.activeItem.selectedLayers.length < 2) {
    alert(“Please select the boundary layer and at least one layer to adjust.”);
    } else {
    var comp = app.project.activeItem;

    // Assuming the first selected layer is the boundary layer
    var boundaryLayer = comp.selectedLayers[0];
    var boundaryRect = boundaryLayer.sourceRectAtTime(comp.time, false);

    // Calculate the number of rows and columns
    var numLayers = comp.selectedLayers.length – 1; // subtract 1 for the boundary layer
    var numRows = Math.ceil(Math.sqrt(numLayers));
    var numCols = Math.ceil(numLayers / numRows);

    var xOffset = boundaryRect.width / (numCols + 1);
    var yOffset = boundaryRect.height / (numRows + 1);

    var currentRow = 1;
    var currentCol = 1;

    // Loop through the other selected layers and position them in a grid
    for (var i = 1; i <= numLayers; i++) {
    var layerToAdjust = comp.selectedLayers[i];
    var layerRect = layerToAdjust.sourceRectAtTime(comp.time, false);

    // Calculate the scale factors for width and height
    var scaleX = (xOffset / layerRect.width) * 100;
    var scaleY = (yOffset / layerRect.height) * 100;

    // Use the smaller scale factor to ensure the layer fits inside its grid cell
    var newScale = Math.min(scaleX, scaleY);
    layerToAdjust.scale.setValue([newScale, newScale]);

    // Position layer in the grid
    var newX = boundaryLayer.position.value[0] – (boundaryRect.width / 2) + (xOffset * currentCol);
    var newY = boundaryLayer.position.value[1] – (boundaryRect.height / 2) + (yOffset * currentRow);
    layerToAdjust.position.setValue([newX, newY]);

    // Move to next position in the grid
    currentCol++;
    if (currentCol > numCols) {
    currentCol = 1;
    currentRow++;
    }
    }

    alert(“Layers adjusted to grid successfully!”);

    // Create an undo group for this action
    app.beginUndoGroup(“Create Null and Parent Selected Layers”);

    // Get the active composition and its selected layers
    var comp = app.project.activeItem;
    var selectedLayers = comp.selectedLayers;

    // Create the null object
    var nullLayer = comp.layers.addNull();
    nullLayer.name = “Parent Null”;

    // Parent the selected layers to the null
    for (var i = 1; i < selectedLayers.length; i++) {
    selectedLayers[i].parent = nullLayer;
    }

    // End the undo group
    app.endUndoGroup();

    }

  • Shane Shornock

    October 25, 2023 at 5:35 pm in reply to: Using a layer as a boundary for other layers

    I am attaching an example from last year’s video I created. Each state has people who represent it. I was able to use ChatGPT and get what I wanted. I don’t know if anyone wants to improve on it. I am also attaching the video of the script working and I will attach here the script

  • Shane Shornock

    July 10, 2009 at 11:34 pm in reply to: Jitter in motion in After Effects

    https://www.youtube.com/watch?v=OSiHZOM8rvw

    Some contents or functionalities here are not available due to your cookie preferences!

    This happens because the functionality/content marked as “Google Youtube” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.

  • Shane Shornock

    March 7, 2009 at 12:54 am in reply to: repeat every four seconds

    Thank you very much

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy