Expanding a lot of symbols via script
Due to a long unresolved glitch, I'm writing a script that expands all symbols before saving a pdf.
If I were to do this without a script, I would go to the symbols pane, select all symbols in the list, click the trash can icon, and choose to expand all instances in the next dialog.
I'm not sure how to replicate these actions with a script, but here's my best try:
app.selection = [];
for(i=0; i<doc.symbolItems.length; i++)
doc.symbolItems[i].selected = true;
app.executeMenuCommand("Expand3");The strange thing is that when this code runs, only some of the symbols are expanded. I ran the code repeatedly on a file with 248 symbolItems on the canvas. First iteration expanded 77 symbols. The next iteration expanded 59 symbols. Then 34, 37, 36, and finally the last 5. If I run it again, it expands the same symbols in the same order.
I thought this was a problem with the script until I manually selected all the symbols and clicked "Object > Expand..." and got the same result. Only a portion of the symbols expanded. Is there some sort of upper limit to what the "Object > Expand..." command can handle until or something? It's strange that the number of expanded symbols is inconsistent. Maybe it depends on the complexity of the symbols?
Whatever the cause, I get the feeling that there's a better way to do this other than having the script just hunt down symbols and keep opening the "Object > Expand..." dialog until none remain. Is there a way to directly access the commands in the symbol pane instead?
