SYMBOLS COUNT TABLE

New Here ,
Jun 04, 2018 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?

TOPICS
Scripting

Views

509

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
community guidelines

correct answers 2 Correct Answers

Valorous Hero , Jun 05, 2018 Jun 05, 2018
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
Adobe Community Professional , Jul 10, 2020 Jul 10, 2020
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 ( pr...

Likes

Translate

Translate
Valorous Hero ,
Jun 05, 2018 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
community guidelines
New Here ,
Jun 05, 2018 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
community guidelines
Community Beginner ,
Jul 10, 2020 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
community guidelines
Adobe Community Professional ,
Jul 10, 2020 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
community guidelines
Community Beginner ,
Jul 10, 2020 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
community guidelines
Adobe Community Professional ,
Jul 10, 2020 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
community guidelines
Community Beginner ,
Jul 10, 2020 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
community guidelines
New Here ,
Nov 05, 2020 Nov 05, 2020

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

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
community guidelines
Adobe Community Professional ,
Nov 05, 2020 Nov 05, 2020

Copy link to clipboard

Copied

LATEST

Hi keith, what do you mean? can you elaborate?

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
community guidelines