On 01/08/2017 at 07:35, xxxxxxxx wrote:
Hi,
I'm note quite sure what the referenced muliMaterial is and how the sub-materials are organized/handled. Are the sub-materials normal materials inside the Material Editor or are they handled differently?
In any case this situation needs some special handling and a few corner cases will have to be considered.
You will also need to take care of situations, where the original scene, where stuff is being copied from, got already closed, when the paste operation is happening. Fortunately there's always only one Copy/Paste operation on the fly at any given time.
And here are your tools:
You will need to implement a SceneHook in order to receive the following two messages (well, actually same type, but different sub-type) : MSG_DOCUMENTINFO with the following sub-types: MSG_DOCUMENTINFO_TYPE_COPY and MSG_DOCUMENTINFO_TYPE_PASTE, the received data is of type DocumentInfoClipData.
On MSG_DOCUMENTINFO_TYPE_COPY you will receive an AtomArray with the entities being copied. There's also a BaseContainer, which you can use to transfer data to the pasting side. I recommend to store your own BaseContainer with your plugin ID inside that container. I have doubts the provided AliasTrans will help in your situation, but I might be wrong. So upon receiving this message you can determine if any of your multiMaterials is involved in the copy operation and you can prepare whatever data you need for the paste and to perhaps fix links on paste. As said before therefore you can use the provided BaseContainer or, as there's only one Copy/Paste at a time, also global variables come to mind. Just be careful to do proper cleanup.
And then on MSG_DOCUMENTINFO_TYPE_PASTE you can do all the needed stuff, as inserting materials, repairing links and so on and so forth.
Sorry, I have no ready made solution, but i think, with these messages you should be able to achieve what you want.