1
Engaged
,
/t5/illustrator-discussions/copy-selected-layer-names-sub-layers-by-script/td-p/14142621
Oct 09, 2023
Oct 09, 2023
Copy link to clipboard
Copied
Helllo Friends,
is there a way to copy selected layer names (sub layers), by Script ?
TOPICS
How-to
,
Scripting
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
1 Correct answer
Enthusiast
,
Oct 09, 2023
Oct 09, 2023
//@target illustrator
app.preferences.setBooleanPreference('ShowExternalJSXWarning', false); // Fix drag and drop a .jsx file
// Main function
function main() {
if (!documents.length) return;
if (!selection.length || selection.typename === 'TextRange') return;
var doc = app.activeDocument;
var sel = app.selection;
var names = [];
for (var i = 0; i < sel.length; i++) {
var str = getName(sel[i]);
if (!isEmpty(str)) names.push(getName(sel[i]));
}
if (names.length) setCli
...
Explore related tutorials & articles
Enthusiast
,
/t5/illustrator-discussions/copy-selected-layer-names-sub-layers-by-script/m-p/14145005#M383296
Oct 09, 2023
Oct 09, 2023
Copy link to clipboard
Copied
//@target illustrator
app.preferences.setBooleanPreference('ShowExternalJSXWarning', false); // Fix drag and drop a .jsx file
// Main function
function main() {
if (!documents.length) return;
if (!selection.length || selection.typename === 'TextRange') return;
var doc = app.activeDocument;
var sel = app.selection;
var names = [];
for (var i = 0; i < sel.length; i++) {
var str = getName(sel[i]);
if (!isEmpty(str)) names.push(getName(sel[i]));
}
if (names.length) setClipboard(names.join('\n'));
}
// Get item name of different types
function getName(item) {
var str = '';
if (item.typename === 'TextFrame' && isEmpty(item.name) && !isEmpty(item.contents)) {
str = item.contents;
} else if (item.typename === 'SymbolItem' && isEmpty(item.name)) {
str = item.symbol.name;
} else {
str = item.name;
}
return str;
}
// Check empty string
function isEmpty(str) {
return str.replace(/\s/g, '').length == 0;
}
// Copy dummy TextFrame content to clipboard
// Function by Tom Scharstein https://github.com/Inventsable
function setClipboard(str) {
var prev = app.selection;
selection = null;
var idoc = app.activeDocument;
var tlayer = idoc.layers.add();
var tframe = tlayer.textFrames.add();
tframe.contents = str.replace(/^\s*||\s*$/, "");
tframe.translate(10);
tframe.selected = true;
app.copy();
tlayer.remove();
app.selection = prev;
}
// Run script
try {
main();
} catch (e) {}
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
j.khakase
AUTHOR
Engaged
,
/t5/illustrator-discussions/copy-selected-layer-names-sub-layers-by-script/m-p/14145529#M383335
Oct 10, 2023
Oct 10, 2023
Copy link to clipboard
Copied
Yes, Perfectly work as per need, Thank you so much @Sergey Osokin Amezing!
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Enthusiast
,
/t5/illustrator-discussions/copy-selected-layer-names-sub-layers-by-script/m-p/14154479#M383736
Oct 13, 2023
Oct 13, 2023
Copy link to clipboard
Copied
I also have an update to BatchRenamer v.1.4 where you can export object names to TXT instead of copying them to the clipboard.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
j.khakase
AUTHOR
Engaged
,
LATEST
/t5/illustrator-discussions/copy-selected-layer-names-sub-layers-by-script/m-p/14163682#M384278
Oct 16, 2023
Oct 16, 2023
Copy link to clipboard
Copied
Thank you, this will be great help
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

