Copy link to clipboard
Copied
Is it possible to undo an entire JSFL tool's script with just one press of CTRL + Z?
For example, the following JSFL tool script allows a user to click on a shape and smooth it by running Animate's smoothSelection() method several times.
Each time the smoothSelection() method runs, an extra undo step is added to the history panel. So is there any way to reduce it to one step while keeping the same logic?
Thank you greatly for any assistance.
var doc = fl.getDocumentDOM();
function configureTool(){
var toolObj = fl.tools.activeTool;
toolObj.setIcon("ExampleTool.png");
toolObj.setMenuString("Example Tool");
toolObj.setToolName("Example Tool");
}
function mouseDown(){
point = fl.tools.penDownLoc;
doc.mouseClick({x: point.x, y: point.y}, false, false);
smoothClickedShape();
}
function smoothClickedShape(){
for (var i = 1; i <= 10; i++) {
doc.smoothSelection();
}
}
Copy link to clipboard
Copied
no, i don't think so.
Copy link to clipboard
Copied
I've reverse-engineered Animate a bit, and here's what I can say from my experience.
Basically, JavaScript engine inside Animate works in such a way that you essentially directly call the program's internal functions, with some overhead for data converting from JS.
And usually, each edit call is accompanied by a boolean indicating whether to save your action to the undo buffer. For calls from JS, this is usually enabled. But the point is that the undo buffer doesn't know whether your JS script is being executed or not, so it can save your actions, for example, to a specific group to later undo your entire script.
So the short answer - no, it's impossible.
Copy link to clipboard
Copied
Thank you for looking into this @DaniilSV ! It looks like I might have to reduce the number of steps in my tool script instead.
The only workaround I can think of, would be using fl.runScript() with an extra script to possibly get a combined "Run Command" history step instead of having all my tool's actions being separate steps.
I'm just unsure whether that would work and if there's a way to send vairable values from the tool script to the separate script.
Such as a variable that would control the number of times smoothSelection() is run.
Copy link to clipboard
Copied
it won't work, but it doesn't hurt to try.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now