8 Replies Latest reply on May 17, 2016 2:07 AM by Toto RoToTO

    Illustrator pathItem.onEdit

    erickk56243057 Level 1

      I'm developing an extension with HTML5 Panels. I'd like to add an event listener or callback function so that a script is triggered to run when a path is being edited. I can't seem to find any documentation on this. Does anyone have ideas for how to do this?  Working in JS/Extend Script

        • 1. Re: Illustrator pathItem.onEdit
          Mylenium Most Valuable Participant

          As far as I know there is no such thing. Unless actually used/ triggered, scripts don't track any activity and there is no global evaluation loop or messaging system that could fire scripts merely based on editing an object.



          • 3. Re: Illustrator pathItem.onEdit
            Qwertyfly... Level 4

            the only way I can think of doing this would be very hack and prob cause some major issues.


            setInterval(function(){ isSelected(); },500);


            if the above is in your main JS file we now have a timer that triggers the function isSelected every half a second.


            now you can use that function to ask illustrator if an item is being worked on and use a callback to get the result back to your HTML panel


            lowering the time would make it more responsive but chew lots of resources

            upping the time makes the script slow to respond but improves overhead.


            I should note that I have not tried this.

            no reason it should not work.

            but I don't think it is viable for a real world solution.

            but I may be wrong on that too.

            maybe if I find some time in the next week or so I will give it a test.

            if I do I will post my results.

            • 4. Re: Illustrator pathItem.onEdit
              Toto RoToTO Level 3

              Such a thing could be done using C++ plugin.

              You have to use notifiers to be notify when a item is updated or modified.

              I have never done that in script.

              Using timer is never a great idea!



              • 5. Re: Illustrator pathItem.onEdit
                Qwertyfly... Level 4

                using a short timer in a never ending loop is not a great idea.

                never using a timer is a big call as there are many perfectly valid and acceptable uses of a timer.


                if you have never coded in a language like C++, and have never used visual studio, etc. etc. then a traditional plugin is a big task to write. the new HTML panels are a small step if your comfortable with javascript and the illustrator dom.


                lets take and example of what I thought the OP may be trying to accomplish:


                script does a bunch of stuff,

                now it want user to do something.

                here it does the polling using the timer.

                when done the script continues.


                in a case like this you might be able to get away with a timed loop as it is only running for a short time.


                if the OP intends to make a new custom tool or something that is going to spend all day listening for user interaction, then I would be confident of it crashing, and chewing resources, and I would not recommend it.

                • 6. Re: Illustrator pathItem.onEdit
                  Toto RoToTO Level 3

                  I do agree. There are many acceptable uses for using timers.

                  But, often, there are better solutions available.


                  In his case, I'm not 100% sure that doing that using script is the best solution. (fast, efficient, robust, ....).

                  You can definitely do it, but I won't. I'd rather do that using C++ plugins (SDK).


                  This thread was added to Illustrator SDK forum, so I guess Erickk knows C++ erickk56243057




                  • 7. Re: Illustrator pathItem.onEdit
                    Qwertyfly... Level 4

                    is there a dedicated forum for HTML panels?

                    If so I must know...


                    as the SDK includes HTML panel examples, I assumed that the SDK forum would be the place to talk about them.

                    • 8. Re: Illustrator pathItem.onEdit
                      Toto RoToTO Level 3

                      I do try to get answers from here:

                      Creative Suite Extension Builder


                      or here:

                      Creative Suite SDK


                      But no very efficient!