Copying/Pasting GvNodes?
-
Hi!
I am writing a plugin that utilizes a custom node editor based on Xpresso (GvNodeMaster, GvNodeGUI, etc.), displayed in a GeDialog.Now I would like to implement Copy/Paste functionality, i.e. to be able to copy and paste selected GvNodes both within a single GvNodeMaster and between different GvNodeMasters. My GvNodeMasters are owned and stored within custom BaseMaterials.
-
Is there some built in functionality I could use for this? The Xpresso editor implements this functionality, is there any way I can call those copy/paste functions?
-
If not, how do I create a copy of a GvNode and insert it into another GvNodeMaster? Using GetClone() does not seem to work, which makes sense as GvNode according to the docs are not really normal BaseList2D:s*
Any suggestions?
Thanks!
/Filip*) From the docs: "The GvNode is a double BaseList2D node. Internally it has an operator that corresponds to GvOperatorData. Use GetOperatorContainer() to access most parameters."
-
-
Hey @Filip,
thank you for reaching out to us. You can call the commands for copy and paste of the Xpresso editor:
CallCommand(300001010); // Copy CallCommand(300001011); // Paste
Appart from that, the general rule "we do not expose UI functionalities but the data structures behind them" applies. There is no Object Manager interface, there is no Material Manager interface, and there is also no Xpresso Editor interface.
So, if you want to clone something , you should use
GetClone
. That the method does not work or thatGvNode
is not a 'really normal'C4DAtom
I would call untrue without proof/demonstration. Not quite sure what the person writing that sentence in the docs meant, but aGvNode
should be copyable. This is how the Xpresso editor implements node copying (there is a bit more going on, but this is the end of the call chain). TheInternal
's are there because this is code from our internal types, but they are wrapped by the public ones, theGvNode
you are using.GvInternalNode* GvInternalNodeMaster::CopyNode(GvInternalNode *source) { return (GvInternalNode*)source->GetClone(COPYFLAGS::NONE, nullptr); }
As always, questions without your code are usually not so good, as we then have to speculate, which makes things a lengthy process.
Cheers,
FerdinandPS: There are also the copy buffer methods on
GvNodeMaster
if you want to preserve connections, copy multiple nodes at once etc.:https://developers.maxon.net/docs/cpp/2024_4_0/class_gv_node_master.html
-
"PS: There are also the copy buffer methods on GvNodeMaster if you want to preserve connections, copy multiple nodes at once etc.:"
-That looks like it might be exactly what I need! Thanks a lot!