Copy Nodes to System Clipboard as Text (JSON?)

I posted this on R-C-S. It got enough attention, I think, that I felt it reasonable to open the topic here where actual potential dev details could be worked out. (It exists in Davinci Resolve’s “BlackMagic Fusion” according to intracube, and possibly other softwares.)

For users to share nodes in chat and possibly pastebins, it would be great to copy to the System clipboard in a text format, and to Paste from System Clipboard as text. (Whether this demands a custom format or something like JSON I don’t know.)

The initial issues to resolve would be, I think:

  1. Converting node data to a sensical format and back
  2. Handling incompatibilities or corrupt text upon paste
  3. Incorporating the minimal needs for sharing, without additional complications like drivers, keyed values, etc.

For 2 (incompatibilities/corruption), we could put the blender version in the text, but it’s not necessary. “Some node data did not match your Blender capabilities. Check the console for details.”

In console you might see, “Text Node (Blahblah) output “Imag” not found in Blender’s Node (Gamma)”.

For 3 (supported retained data), we could provide a status message like: “Copy successful, but some features not copied. See console for details.”

Original r-c-s post:


this would be really helpfull, but how would you paste the text back into blender as nodes.
it needs some kind of inputfield

From what I can tell, platforms have a way of either conveying, or at least allowing conversion of clipboard content types. (For instance, X11 uses XConvertSelection() to actually retrieve the clipboard contents, and you specify the desired targets’ types).

So, if it’s text, then a quick evaluation can determine if it’s the format “we” decide to use (like checking if it’s valid json).

(It’s best not to rely on something more elaborate than just ‘text’ or not – you don’t want to require it to be, say, a mime-type like “application/json”, if that’s even possible, because that would screw up sharing it through forums, pastebins, chat, etc.)