Script Overview
This script automates the process of duplicating a selected object across all artboards in an open Adobe Illustrator document. It maintains the exact position of the object relative to each artboard, making it especially useful for designers working with multi-artboard files who need consistent elements (e.g., logos, watermarks) across all artboards.
How It Works
- Document Verification:
- The script first checks if an Adobe Illustrator document is open. If not, it alerts the user and stops execution.
- Object Selection:
- The script prompts the user to select an object they want to duplicate. If no object is selected, it notifies the user and ends.
- Artboard Iteration:
- The script loops through all the artboards in the document.
- Object Duplication:
- For each artboard, it duplicates the selected object and calculates the required positional offset to place the duplicate in the same relative position on the current artboard as the original object on the first artboard.
- Completion:
- Once duplication is complete, the user receives a confirmation alert.
How to Use the Script
- Setup:
- Open your Adobe Illustrator document.
- Ensure there are multiple artboards in the document and at least one object selected.
- Save the Script:
- Copy the provided script code and save it as a
.jsx
file (e.g.,DuplicateObjectToArtboards.jsx
).
- Copy the provided script code and save it as a
- Run the Script:
- In Illustrator, go to
File > Scripts > Other Script...
and select your saved script file.
- In Illustrator, go to
- Result:
- The selected object will be duplicated to all artboards in its exact position.
Key Features
- Automated Duplication: Eliminates the need to manually copy and paste objects onto each artboard.
- Precision Placement: Ensures that duplicates are aligned perfectly across all artboards.
- User-Friendly Alerts: Notifies the user if any prerequisite steps are missing, like selecting an object or opening a document.
JavaScript
Copy_Selected_Object_and_Paste_it_to_All_Artboards (0 downloads )
// Check if a document is open
if (app.documents.length > 0) {
var doc = app.activeDocument;
// Prompt user to select an object to duplicate
var selectedObject = doc.selection[0];
if (!selectedObject) {
alert("Please select an object to duplicate.");
} else {
// Loop through all artboards
for (var i = 0; i < doc.artboards.length; i++) {
var currentArtboard = doc.artboards[i];
// Duplicate the selected object
var duplicatedObject = selectedObject.duplicate();
// Move the duplicated object to the same position on the current artboard
var dx = currentArtboard.artboardRect[0] - doc.artboards[0].artboardRect[0];
var dy = currentArtboard.artboardRect[1] - doc.artboards[0].artboardRect[1];
duplicatedObject.position = [selectedObject.position[0] + dx, selectedObject.position[1] + dy];
}
alert("Object duplicated to all artboards.");
}
} else {
alert("No document open. Please open a document to run this script.");
}