3 Replies Latest reply on May 28, 2017 8:17 AM by uniqued_tol

    Can I take the running script off the hook and re-enable it when I give commands with groups of items.

    uniqued_tol Level 1

      I have anchored grouped items in the story. I want to get them out of the story and get them out of the group. After I have done a few operations by hand, I want to group again and get to the anchored place. Is it possible to do it with a single script?

       

      Scrip to do that?

      - anchored group from group.

      - I will untie the group and do a few things. (In this case the script will remain inactive)

      - When I do it with the group again, the script will be active and it will be positioned at the previous anchored position.

       

      EXAM.jpg

       

      Thank you for your ideas.

        • 1. Re: Can I take the running script off the hook and re-enable it when I give commands with groups of items.
          Laubender Adobe Community Professional & MVP

          Hi,

          I don't know how your level of expertise is with scripting.


          If you want to put all functionality in one single script run once* you have to work with event listening.
          Basically that's a mechanism that would watch things you do. In your case with groups of a particular story and the items of that group once it is ungrouped. And if one or all of the items is or are grouped again ( that would be a logical entry point for doing something automatically after a first step ).

           

          *And you could build this one script as a toggle.
          Run it once it would be activated. Run it a second time activities will stop, the listeners would be removed.

           

          Way easier—perhaps 1 % in effort compared to the event listening approach—you could work with at least two scripts.


          1. One that is running on the selected anchored group.
          Perhaps doing a duplicate of the group and ungroup the duplicate.


          2. And one that you are running on the selected group on the page after you finished what you like to do.

          That script would exchange the anchored group with the selected group on the page.

           

          You could even have a third script, that would be run after the second one:

          3. Select the next anchored group in the story.

           

          All three scripts would run in the same target engine so they could share functions and declared variables only for the scripts using that engine. What a target engine statement is? See here on page 9:

          https://www.adobe.com/content/dam/Adobe/en/devnet/indesign/cs5_docs/indesign_scripting/fea ture-development-with-scriptin…

           

          A tiny example:

          Storing Data In A Target Engine · fabianmoronzirfas/extendscript Wiki · GitHub

           

          If you need a user interface for running the scripts see Peter Kahrel:

          ScriptUI for dummies | Peter Kahrel

           

          Regards,
          Uwe

          1 person found this helpful
          • 2. Re: Can I take the running script off the hook and re-enable it when I give commands with groups of items.
            uniqued_tol Level 1

            Laubender  wrote

             

            Hi,

            I don't know how your level of expertise is with scripting.


            If you want to put all functionality in one single script run once* you have to work with event listening.
            Basically that's a mechanism that would watch things you do. In your case with groups of a particular story and the items of that group once it is ungrouped. And if one or all of the items is or are grouped again ( that would be a logical entry point for doing something automatically after a first step ).

             

            *And you could build this one script as a toggle.

            Way easier—perhaps 1 % in effort compared to the event listening approach—you could work with at least two scripts.


            1. One that is !running on the selected anchored group.
            Perhaps doing a duplicate of the group and ungroup the duplicate.


            2. And one that you are running on the selected group on the page after you finished what you like to do.

            That script would exchange the anchored group with the selected group on the page.

             

            You could even have a third script, that would be run after the second one:

            3. Select the next anchored group in the story.

             

             

            Thanks Uwe I think the second way is more understandable for me. I completed the first and second steps. Step 3 is hard for me.

             

             #targetengine "session01"
            myObjem=app.selection[0];
            
            myObjem1=myObjem.duplicate();
            
            
                    myObjem1.move([-14,14]);
                                    try{
                        myObjem1.ungroup();
                        }catch(e){};