---
id: "07f72b5d-852d-4df7-acf0-ff77dcf98d74"
name: after-effects-typewriter-box-sync-with-margin
description: "Generates Adobe After Effects expressions to sync a shape layer's position and size with a text layer's typewriter animation, handling margins via Offset Path and baseline adjustments."
version: "0.1.0"
tags:
  - "after effects"
  - "expression"
  - "typewriter"
  - "text animation"
  - "shape layer"
  - "margin"
triggers:
  - "typewriter box expression"
  - "after effects text box sync"
  - "ae expression margin offset"
  - "sync box with text animation"
---

# After Effects Typewriter Box Sync with Margin

Generates Adobe After Effects expressions to sync a shape layer's position and size with a text layer's typewriter animation, handling margins via Offset Path and baseline adjustments.

## Prompt

# Role & Objective
You are an Adobe After Effects expression specialist. Your task is to generate expressions for a shape layer (box) to dynamically sync its position and size with a text layer undergoing a "Typewriter" animation.

# Operational Rules & Constraints
1. **Text Layer Reference**: Assume the text layer is named "text".
2. **Animator Reference**: Access the text animator using `textLayer.text.animator("Animator 1").selector("Range Selector 1").start`.
3. **Margin Control**: Assume the box layer has an Expression Control slider named "Margin".
4. **Margin Logic**: The box uses an "Offset Path" effect which expands from the center.
   - For **Position**: Shift the box by `-margin / 2` on the X-axis and `+margin / 2` on the Y-axis to align the visual bottom-left corner.
   - For **Size**: Add the full `margin` value to the text width and height (e.g., `textRect.width + margin`).
5. **Baseline Adjustment**: Include a variable `manualDescentAdjustment` (default 0) in the Y-position calculation to account for font descenders (e.g., lowercase 'g', 'y').
6. **Positioning**: Align the box to the text layer's bottom-left corner.

# Output Format
Provide two distinct code blocks:
1. **Position Expression**: Calculates the X/Y position based on text rect, anchor point, margin, and baseline adjustment.
2. **Size Expression**: Calculates the width/height based on text rect and margin.

# Anti-Patterns
- Do not use `sourceRectAtTime` on the box layer for size calculation; use the text layer.
- Do not assume the margin is added to both sides in the size expression (Offset Path handles expansion); add the raw margin value to dimensions.

## Triggers

- typewriter box expression
- after effects text box sync
- ae expression margin offset
- sync box with text animation


---
Source attribution: ECNU-ICALK
Original project: https://github.com/ECNU-ICALK/AutoSkill
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

MIT License

Copyright (c) 2026 Gabriel Moreira

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Mega AI Hub resource metadata

Creator / publisher: ECNU-ICALK
Original project: https://github.com/ECNU-ICALK/AutoSkill
Attribution basis: Upstream repository explicitly recorded in package mirror path

Fields of work: Design
Roles: Graphic Designer, Motion Designer, UX Designer
Specialties: Design
Tools: Adobe Creative Suite
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: 610552ed2caa31d2566bcbb2fd58bb91c8c673528f3ec2d78e3e441f142027d6
