1111357
September 30, 2021, 5:04pm
1
Good day!
How can i clone or copy node?
I want get selection nodes from page (currentPage.selection)
Clone selection nodes and group
Export group to image and submit image to REST API url
Or is there another way, to get one image from selection nodes?
1111357
September 30, 2021, 9:05pm
2
Need NODES (all) save to one IMAGE
I know, that i can group nodes, and group export to image…
But group with original nodes are not good for me, don’t want doing manipulation with original user nodes
Excelent if i take selection nodes, create temp group with clone selection nodes, export image and remove temp group
Gleb
October 1, 2021, 1:17am
3
You can clone each node by calling node.clone()
, push this cloned node to an array and then put this array into figma.group(nodesArray, parentNode)
to create a group from them. group · Figma Developers
Property ‘clone’ does not exist on type ‘SceneNode’.
switch (msg.type) {
case MessageTypes.select:
const { currentPage } = figma
const selectedNode = currentPage.selection;
if (selectedNode.length > 0) {
const clonedNodes: SceneNode[] = []
selectedNode.forEach(node => clonedNodes.push(node.clone()))
const group = figma.group(clonedNodes, currentPage)
}
break;
case MessageTypes.cancel:
figma.closePlugin();
break;
}
Not work
selectedNode.forEach(node => clonedNodes.push(JSON.parse(JSON.stringify(node.clone()))))
You are right, thank you very much!
Ts ignore help me =) and nodes success cloned and grouped
// @ts-ignore
selectedNode.forEach(node => clonedNodes.push(node.clone()))
@ts-ignore will disable TS for the rest of the file. Maybe you can do: (node as ComponentNode).clone()
Gleb
Closed
November 22, 2021, 8:00am
8
This topic was automatically closed after 15 days. New replies are no longer allowed.