5 Replies Latest reply on Jun 14, 2017 6:37 AM by Silly-V

    How do I find a live paint object in an Illustrator script?

    ShinWooJin Level 1

      The illustrator file has a layer structure and wants to move the objects in each layer to Artboard.

      To do that, you need to figure out the model of the Illustrator object and move it automatically, but you can not find an object called "Live Paint" in the script. I want to know how to find the Live Paint object and select or delete it.

        • 1. Re: How do I find a live paint object in an Illustrator script?
          Loic.Aigon Adobe Community Professional

          Hi,

           

          Seems like liveTrace objects are referenced as PluginItem. However that might be a too generic type to properly grab the livetrace objects ?

           

          FWIW

           

          Loic

          www.ozalto.com

          • 2. Re: How do I find a live paint object in an Illustrator script?
            moluapple Level 4

            AFAIK, the so called PluginItems have 5 types:

            - Flare

            - LiveBlends

            - Tracing

            - Envelope

            - LivePaint

             

            The lucky one of them is "Tracing", using `PluginItem.isTracing` property can get it.

            // - Tracing
            app.selection[0].isTracing;
            

             

            For the others, we have to do some tests.

             

            First, select one PluginItem a time, and duplicate it.

            Then:

            // - LivePaint
            app.executeMenuCommand('Expand Planet X');
            app.selection[0].typename === 'GroupItem';
            
            // - Envelope
            app.executeMenuCommand('Release Envelope');
            app.selection.length > 1;
            
            // - LiveBlends
            app.executeMenuCommand('Path Blend Release');
            app.selection.length > 1;
            
            // - Flare
            // if not any of above, then it is Flare.
            

            At the end, delete the duplicated(expanded) items.

             

            EDIT:

            Wait! Here comes the six type: Symbol Group. So we have to do more tests to distinguish Flare and Symbol Group.

            Have one PluginItem selected as the same, then

            // - SymbolGroup
            activeDocument.defaultStrokeColor.typename === 'NoColor';
            
            // - Flare
            // again, if not any of above, then it is Flare.
            
            • 3. Re: How do I find a live paint object in an Illustrator script?
              ShinWooJin Level 1

              Thank you first of all. Moluapple

              We attempted to detect the PlugItem's LIvePaint using the code you suggested.

              I tested using AI files shared on Google Drive. The code we tested was:

               

              Var doc = app.activeDocument; 

              For (var i = 0; i <doc.pluginItems.length; i ++) {    

                   If (doc.pluginItems [i] .isTracing)    

                   {        

                       Alert ('tracing detect');        

                       Break;    

                    }

              }

               

              The first thing we want to do is to find the AI file that Live Paint belongs to

              and then use it to change the item with Live Paint to a line with the general properties. Request you to check.

               

              20170607_150900352912_1.ai - Google Drive

              • 4. Re: How do I find a live paint object in an Illustrator script?
                moluapple Level 4

                Hi, to select all live paint objects in active document:

                var d = activeDocument,
                    pi = d.pluginItems,
                    l = pi.length,
                    live = [],
                    i = 0;
                    
                for (; i < l; i++) {
                    app.selection = null;
                    pi[i].duplicate(d, ElementPlacement.PLACEATBEGINNING).selected = true;
                    app.executeMenuCommand('Expand Planet X');
                    if (app.selection[0].typename === 'GroupItem') {
                        alert('Live Paint detected');
                        live.push(pi[i]);
                        // doSomething();
                    }
                    app.selection[0].remove();
                }
                
                app.selection = live;
                
                1 person found this helpful