Thanks for your reply.
After several tries, I found an interesting result.
Currently I have scripts to do the things below
STEP 1: select two items
STEP 2: group two items
Experiment 1
I separate STEP1 and STEP2 into two menu actions in XD plugin
And execute “Select Action” and “Group Action”, one by one and the result is indeed the same to behavior which is operated by users.
Experiment 2
The menu action (scripts) do the Step1 and Step2 in XD Plugin
i.e. selected the items and do the grouping. The result is DIFFERENT, the new group will be under the artboard, not original group.
========= Reference Code ===========
------------------------------------------- Experiment 1 -------------------------------------------
#STEP1
let current = selection.items[0];
let c1 = current.children.at(0);
let c2 = current.children.at(1);
selection.items = [c1, c2];
#STEP2
commands.group();
------------------------------------------- Experiment 2 (ALL-IN-ONE)-------------------------------------------
let current = selection.items[0];
let c1 = current.children.at(0);
let c2 = current.children.at(1);
selection.items = [c1, c2];
console.log(selection.items);
commands.group();
Even for experiment 2, the scripts delay few seconds to do the command.group
It doesn’t work as expected. Any idea or suggestion?
I just want to achieve the same result but have no way to achieve.
XD plugin are not allow to change parent or structure of the tree nodes, only limit to only one node.
I have no way to change parent of the group.
Chris Chang