Highlighted

SYMBOLS COUNT TABLE

New Here ,
Jun 04, 2018

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();

Topics

Scripting

Views

272

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

SYMBOLS COUNT TABLE

New Here ,
Jun 04, 2018

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();

Topics

Scripting

Views

273

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jun 04, 2018 0
Valorous Hero ,
Jun 05, 2018

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();

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 05, 2018 2
New Here ,
Jun 05, 2018

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.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(); 

I´ll try to refine a bit to make a table, but it works anyway.

Thank you !

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 05, 2018 0
Community Beginner ,
Jul 10, 2020

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

Screen Shot 2020-07-10 at 9.34.34 AM.png

Screen Shot 2020-07-10 at 9.51.03 AM.png

 

thank you!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 10, 2020 0
Adobe Community Professional ,
Jul 10, 2020

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?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 10, 2020 0
Community Beginner ,
Jul 10, 2020

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. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 10, 2020 0
Adobe Community Professional ,
Jul 10, 2020

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(); 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 10, 2020 0
Community Beginner ,
Jul 10, 2020

Copy link to clipboard

Copied

Thank you so much, that worked! 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 10, 2020 1