Copy link to clipboard
Copied
It´s possible to make a script that writes a table with all symbols instances count ? how difficult it would be?
var main = function() {
var doc;
if ( !app.documents.length ) {
alert("This scripts needs an open document !");
return;
}
doc = app.activeDocument;
var symbols = doc.symbolItems, n = symbols.length, nSymbol, db = {}, arr = [];
while ( n-- ) {
nSymbol = symbols
.symbol; db[ nSymbol.name ] = db[ nSymbol.name ] || 0;
db[ nSymbol.name ]++;
}
for ( prop in db ) {
arr.push ( prop+" : "+db[prop] );
}
alert( "Result:\r"+arr.join("\r") );
}
main();
Copy link to clipboard
Copied
It´s possible to make a script that writes a table with all symbols instances count ? how difficult it would be?
var main = function() {
var doc;
if ( !app.documents.length ) {
alert("This scripts needs an open document !");
return;
}
doc = app.activeDocument;
var symbols = doc.symbolItems, n = symbols.length, nSymbol, db = {}, arr = [];
while ( n-- ) {
nSymbol = symbols
.symbol; db[ nSymbol.name ] = db[ nSymbol.name ] || 0;
db[ nSymbol.name ]++;
}
for ( prop in db ) {
arr.push ( prop+" : "+db[prop] );
}
alert( "Result:\r"+arr.join("\r") );
}
main();
Copy link to clipboard
Copied
var main = function() {
var doc;
if ( !app.documents.length ) {
alert("This scripts needs an open document !");
return;
}
doc = app.activeDocument;
var symbols = doc.symbolItems, n = symbols.length, nSymbol, db = {}, arr = [];
while ( n-- ) {
nSymbol = symbols
.symbol; db[ nSymbol.name ] = db[ nSymbol.name ] || 0;
db[ nSymbol.name ]++;
}
for ( prop in db ) {
arr.push ( prop+" : "+db[prop] );
}
alert( "Result:\r"+arr.join("\r") );
}
main();
Copy link to clipboard
Copied
thank you very much !
I made a little change in the script making illustrator to paste the results in a text frame, because I coulnd´t copy the text from the alert.
var main = function() {
var doc;
if ( !app.documents.length ) {
alert("This scripts needs an open document !");
return;
}
doc = app.activeDocument;
var symbols = doc.symbolItems, n = symbols.length, nSymbol, db = {}, arr = [];
while ( n-- ) {
nSymbol = symbols
db[ nSymbol.name ] = db[ nSymbol.name ] || 0;
db[ nSymbol.name ]++;
}
for ( prop in db ) {
arr.push ( prop+" : "+db[prop] );
}
var result = doc.textFrames.add();
result.contents = ( "Result:\r"+arr.join("\r") );
result.top = 700;
result.left = 400;
redraw();
}
main();
I´ll try to refine a bit to make a table, but it works anyway.
Thank you !
Copy link to clipboard
Copied
Hello!
Thank you for these!
I am gettign an error. is it becuase I named my symbols? They are all static graphic symbols
thank you!
Copy link to clipboard
Copied
That is a strange error, are you running the script as written or did you have anything running before it, or have extra custom code?
Copy link to clipboard
Copied
I am running it as written. copy and pasted it into sublime text, and then saved it as a .js.
i do not know code so copy and paste is my only option.
Copy link to clipboard
Copied
moving to the new Forums ruined all existing scripts, try this version
var main = function() {
var doc;
if ( !app.documents.length ) {
alert("This scripts needs an open document !");
return;
}
doc = app.activeDocument;
var symbols = doc.symbolItems, n = symbols.length, nSymbol, db = {}, arr = [];
while ( n-- ) {
nSymbol = symbols[n].symbol;
db[ nSymbol.name ] = db[ nSymbol.name ] || 0;
db[ nSymbol.name ]++;
}
for ( prop in db ) {
arr.push ( prop+" : "+db[prop] );
}
var result = doc.textFrames.add();
result.contents = ( "Result:\r"+arr.join("\r") );
result.top = 700;
result.left = 400;
redraw();
}
main();
Copy link to clipboard
Copied
Thank you so much, that worked!
Copy link to clipboard
Copied
Carlos,
Thank you for the excellent script. Is it possible to have the symbol itself show in the resulting list instead of the name? How would a person code that?
Thanks, so much.
rtvkeith
Copy link to clipboard
Copied
Hi keith, what do you mean? can you elaborate?