11 Replies Latest reply on Jun 4, 2012 8:53 AM by Muppet Mark

    Deleting a Used Symbol Generates Error

    dustinwwilson

      I'm having difficulty writing a script that deletes all of the symbols in the document (as opposed to just breaking links or expanding which I apparently cannot do).

      app.sourceDocument.symbols.removeAll();

      When it reaches a symbol that's used in the document somewhere it spits out this error:

      Error 1200: an Illustrator error occurred: 1346458189 ('MRAP')

        • 1. Re: Deleting a Used Symbol Generates Error
          Muppet Mark Level 5

          activeDocument not sourceDocument…?

          • 2. Re: Deleting a Used Symbol Generates Error
            dustinwwilson Level 1

            I've always seen it as activeDocument to select the current document. What's the difference?

            • 3. Re: Deleting a Used Symbol Generates Error
              Muppet Mark Level 5

              have you defined sourceDocument else where?

              • 4. Re: Deleting a Used Symbol Generates Error
                dustinwwilson Level 1

                Oh sorry. yes I meant to type activeDocument. It should be:

                app.activeDocument.symbols.removeAll();

                I've tried it many different ways by using that method, by iterating over symbolItems, by iterating over all the items and finding symbolItems. All of them return that error when I tell it to remove a symbol that is used in the document.

                • 5. Re: Deleting a Used Symbol Generates Error
                  Larry G. Schneider Adobe Community Professional & MVP

                  Just tried your one liner and with symbols.removeAll() it removes the symbols from the Symbol panel. Using it with symbolItems it removes all the instances of symbols from within the document but doesn't touch the symbols in the panel.

                  • 6. Re: Deleting a Used Symbol Generates Error
                    Muppet Mark Level 5

                    This is correct Larry Symbols are whats in the palette… symbol items are their instances in the document the OP didn't state which they wanted to remove but your suggestion should fix that either way… Had the variable sourceDocument been defined earlier in the script then it would not have needed the app. activeDocument on the otherhand is a property of app

                    • 7. Re: Deleting a Used Symbol Generates Error
                      dustinwwilson Level 1

                      sourceDocument never existed in the first place. It was a typo I made when I first typed it in here. The error message seems to be isolated within this one document I have which contains many different symbols. I can run the command on other documents, and it works fine. I'll have to investigate further into what's going on.

                      • 8. Re: Deleting a Used Symbol Generates Error
                        Muppet Mark Level 5

                        Quit the app and the ESTK if thats what you are using to debug… Thats a general scripting error

                        1 person found this helpful
                        • 9. Re: Deleting a Used Symbol Generates Error
                          Larry G. Schneider Adobe Community Professional & MVP

                          Are all Layers and symbol instances unlocked and visible? That's what I would suspect is your problem. You can't delete something that is not visible.

                          1 person found this helpful
                          • 10. Re: Deleting a Used Symbol Generates Error
                            dustinwwilson Level 1

                            Sorry for the late reply. I've tried that, and it helped, but it still spits out that error from time to time. However, I've discovered when you delete a symbol all its symbol items are expanded (which is what I wanted), but all of them are placed into the top layer... which is something I don't want to do. I've pretty much given up on trying to do anything with symbols via normal scripting methods.

                             

                            I do quite a bit of pixel-perfect work in Illustrator since CS5 added features for doing so, but there's a major caveat. If you use symbols you can't do pixel perfect work at all. Even if you have the dimensions of the symbol set perfectly within the pixel grid sometimes they won't render correctly. They even render worse when you attempt to save to an image. The only way around it is to unlock and select everything and break link to symbol. Everything then looks fine and will export fine. You'd think Adobe would have fixed this problem in CS6, but no they haven't.

                             

                            I already use a script to export artboards as individual files, so my thoughts were to combine a script which does this bit of workaround-that-shouldn't-even-be-necessary with that.  There's yet another caveat when exporting artboards as files via scripting. Adobe stupidly removes the rendering methods from scripting, so if your artboards contain text they render out like crap because it exports everything using Art Optimized instead of Type Optimized without any way to change that. To work around that I wrote a script which selected all text objects in the document and rasterized them. I've gotten it to work by rasterizing text, creating an action which does the break link to symbol command and switching to AppleScript which unlocks everything, selects everything, does that action to break link to symbols, executes the artboard exporter script (which is javascript), and lastly undos everything to immediately before the script executed. It's a hacky way to do it, but it seems to work.

                             

                            Only problem I really have is that AppleScript in Illustrator seems to be extremely slow. When selecting everything in the document for instance Illustrator labors for nearly half a minute in a large document when using AppleScript, but if I do the same exact thing in JavaScript it's nearly instantaneous, so as stupid as it sounds I'll have the AppleScript execute JavaScript for selecting everything in the document.


                            Thanks for your help!

                            • 11. Re: Deleting a Used Symbol Generates Error
                              Muppet Mark Level 5

                              Having done a bit of both AppleScript in general will always refresh the GUI on the other hand ExtendScript doesn't unless asked to… this can be quicker but each language has strengths and weaknesses… In AppleScript you can define a script then use the run script command this can improve performance in some cases…