Copy link to clipboard
Copied
Does anyone have a script that can pass the name of the sublayers to CSV?
Thanks
i have this code,
but it does not detect the sublayers.
I don't understand much about scripts, can someone correct it for me?
Hi,
It will give the name of all pageItems in the document
#target illustrator
main();
function main() {
if (!documents.length) return;
var doc = app.activeDocument;
var docTitle = doc.name;
var docTitle = docTitle.substring(0, docTitle.length - 3);
var textFile = File('~/Desktop/' + docTitle + '_Layers.csv');
var docText = '';
var names = [];
for (var i = 0; i < doc.pageItems.length; i++) {
if (doc.pageItems[i].name != '')
names.push(doc.p
...
Copy link to clipboard
Copied
Hi,
Try following snippet
#target illustrator
main();
function main() {
if (!documents.length) return;
var doc = app.activeDocument;
var docTitle = doc.name;
var docTitle = docTitle.substring(0, docTitle.length - 3);
var textFile = File('~/Desktop/' + docTitle + '_Layers.csv');
var docText = '';
var layersName = [];
getAllLayers(doc, layersName);
docText = layersName;
textFile.open('e');
textFile.write(docText);
textFile.close();
}
function getAllLayers(container, layersName) {
for (var i = 0; i < container.layers.length; i++) {
layersName.push(container.layers[i].name);
getAllLayers(container.layers[i], layersName);
}
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Could you please attach the your ai files. It may possible only single layer exists and other are groups not layers. Or may be screen shot of your Layer panel.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hi,
It will give the name of all pageItems in the document
#target illustrator
main();
function main() {
if (!documents.length) return;
var doc = app.activeDocument;
var docTitle = doc.name;
var docTitle = docTitle.substring(0, docTitle.length - 3);
var textFile = File('~/Desktop/' + docTitle + '_Layers.csv');
var docText = '';
var names = [];
for (var i = 0; i < doc.pageItems.length; i++) {
if (doc.pageItems[i].name != '')
names.push(doc.pageItems[i].name)
}
docText = names;
textFile.open('e');
textFile.write(docText);
textFile.close();
}
If you want item of only variables layers then use following
#target illustrator
main();
function main() {
if (!documents.length) return;
var doc = app.activeDocument;
var docTitle = doc.name;
var docTitle = docTitle.substring(0, docTitle.length - 3);
var textFile = File('~/Desktop/' + docTitle + '_Layers.csv');
var docText = '';
var names = [];
for (var i = 0; i < doc.pageItems.length; i++) {
if (doc.pageItems[i].name != '' && doc.pageItems[i].layer.name == 'variables')
names.push(doc.pageItems[i].name)
}
docText = names;
textFile.open('e');
textFile.write(docText);
textFile.close();
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hello,
I don't see the script, where can I get it?
Copy link to clipboard
Copied
hey @siscub42209571
the fisrt snippet provided by @Charu Rajput in the first comment above
Copy link to clipboard
Copied
Yes first script gives name of the sublayer, but the actual problem is @siscub42209571 document does not have sublayers. As per the screen shots it is not sublayers but page items.
I hope updated version of the script will help @siscub42209571
Copy link to clipboard
Copied
Yessss,
Yes Yes
now it works, thank you so much