Best way of implementing copy and pasting of nodes in graph view?

Hey guys,

I’m building a dialogue editor for our project and my designer asked if I could implement copy and pasting. We stuck with 2018.3.14f1 and can’t afford to risk updating because it might break some other critical plugins. I’m using graph view and because the version is a bit older the graph view api probably is too.

So I’m wondering if there’s a simpler inbuilt way of implementing copy and paste because when you right click in the graph view there’s a context menu that appears but with greyed out cut/copy/paste.

Or do I have to manually implement it myself from scratch?


I have looked a bit into source code, haven’t dug deeper. But I suppose that you should handle copy/pasting yourself via callbacks. It makes sense because as a developer you might want to have control over how your nodes are copied and if they are allowed to be copied at all (some nodes might have restrictions in your graph). You can also look at ShaderGraph source code to see how it’s done there. I hope with this information you can see what you need to look up into and have an idea where to start.

Please, let me know if you find a solution to this, as I would like to implement this functionality myself.

1 Like

I have looked into it and I could handle it like this :


3 Likes

Yep those are the correct events to listen to.
I’m still using the same old beta version so the API might be different.
.serializeGraphElements called when Ctrl+C pressed.
.unserializeAndPaste and probably .canPasteSerializedData called when Ctrl+V pressed.

Cheers guys

1 Like

Hey sorry to rez a dead thread here but this is the only fourm post I’ve found that talks about this. My quesetion is how do I go about calculating new node postions? I wanna keep all in the nodes in there same postions when I paste them but just translate X units down or up towards the mouse. Whats the best way implement this?

So in this video, Mert (the guy) implements something similar to what you want, starting at around 8:00, he’s not copying but creating new nodes, but I’m sure you’ll figure it out.
Video’s the third part of the unfinished series, so if his code is too different from yours you might wanna skim through fist two parts.

Hey thanks for the response. Looking at that math it would really only work when your pasting only one node. Here is an example with ue4 blueprints of what am trying to achive. Notice how when I paste multiple nodes that they stay in there group and maintain there realative offsets from each other.7533176--930143--Example.gif