I am trying to create a plugin like this link.
However, I faced the same problem.
What is the “TRANSFORM EVENT” indicated in the solution?
I am trying to create a plugin like this link.
However, I faced the same problem.
What is the “TRANSFORM EVENT” indicated in the solution?
Hi Taka,
From memory, I would have been using batchPlay that looked something like the example here, with the action being transform:
You can get more info about events using something like the Alchemist plugin or using a listener function like that in the batchPlay documentation
Thank you for your reply, jessica!
However, I still do not understand…
I had thought that moving a selection on a layer would provide “TRANSFORM EVENT” instead of “toolModalStateChanged” and “historyStateChanged”.
However, I noticed that “transform” is provided by performing another action (e.g. selecting another layer or clicking elsewhere) after scaling, rotating, etc.
If I want to record a “cut event” immediately after moving something, should I do a deselect?
I think you are trying to do this
async function moveSelection() {
const result = await batchPlay(
[
{
_obj: "cut",
_target: [
{
_ref: "channel",
_property: "selection"
}
],
to: {
_obj: "offset",
horizontal: {
_unit: "distanceUnit",
_value: 0
},
vertical: {
_unit: "distanceUnit",
_value: -37.5
}
},
_options: {
dialogOptions: "dontDisplay"
}
}
],
{
synchronousExecution: false,
modalBehavior: "wait"
}
);
}
async function runModalFunction() {
await executeAsModal(moveSelection, {"commandName": "Action Commands"});
}
await runModalFunction();
Thank you for your reply, JasonM!
The command you wrote appears to be just something that does a cut event.
What I would like to implement is the function to record the event when the user moves something and execute that event on other layers.
I’m facing a problem that I can’t get that cut event until after I do some operation in that case.
I see…I do not know how to do that
Hi Taka,
Sorry for the delay and unhelpful previous response.
Because I was having trouble with firing these events after a “move”, instead of listening for a “move”, I switched to listening for a transform event (ctrl + T, and hitting enter when finished) instead. This also had the benefit of not just necessarily performing a translation but also for any rotation, scaling etc. could also be done to the other layers as well. But unfortunately didn’t end up pursuing it after a “move” as I didn’t have any success forcing it without performing another action. I hope that makes more sense.
Best of luck!
If you store the selection, and then they use Transform (ctrl T) to move the selection, you can then likely reselect that selection on the other layers and perform the last transform.
await batchPlay(
[
{
_obj: "transform",
_target: [
{
_ref: "layer",
_enum: "ordinal",
_value: "targetEnum"
}
],
lastTransform: true,
_options: {
dialogOptions: "dontDisplay"
}
}
],
{}
);