Last active
November 8, 2024 13:59
-
-
Save creold/23ac4d87bd1d3039c050a20af218dae1 to your computer and use it in GitHub Desktop.
Move the content of the active artboard to a new layer in Adobe Illustrator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Move the content of the active artboard to a new layer | |
Discussion: https://community.adobe.com/t5/illustrator-discussions/move-layers-groups-and-masks-to-new-layer/td-p/13256473 | |
Author: Sergey Osokin, email: [email protected] | |
Check my other scripts: https://github.com/creold | |
Donate (optional): | |
If you find this script helpful, you can buy me a coffee | |
- via Buymeacoffee https://www.buymeacoffee.com/aiscripts | |
- via DonatePay https://new.donatepay.ru/en/@osokin | |
- via Donatty https://donatty.com/sergosokin | |
- via YooMoney https://yoomoney.ru/to/410011149615582 | |
- via QIWI https://qiwi.com/n/OSOKIN | |
*/ | |
//@target illustrator | |
app.preferences.setBooleanPreference('ShowExternalJSXWarning', false); // Fix drag and drop a .jsx file | |
// Main function | |
function main() { | |
if (!/illustrator/i.test(app.name)) { | |
alert('Error\nRun script from Adobe Illustrator'); | |
return false; | |
} | |
if (!documents.length) { | |
alert('Error\nOpen a document and try again'); | |
return false; | |
} | |
var doc = activeDocument; | |
selection = null; | |
redraw(); | |
doc.selectObjectsOnActiveArtboard(); | |
if (selection.length) { | |
var idx = doc.artboards.getActiveArtboardIndex(), | |
lyr = doc.layers.add(); | |
lyr.name = doc.artboards[idx].name; | |
lyr.color = selection[0].layer.color; | |
for (var i = 0; i < selection.length; i++) { | |
selection[i].move(lyr, ElementPlacement.PLACEATEND); | |
} | |
selection = null; | |
redraw(); | |
} | |
} | |
// Run script | |
try { | |
main(); | |
} catch (e) {} |
Author
creold
commented
Oct 18, 2022
More about script in Telegram channel.
Alexander Ladygin has a similar script artboardItemsMoveToNewLayer, which has additional options in the dialog mode.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment