On 12/08/2016 at 03:53, xxxxxxxx wrote:
Cinema 4D Version: R17
Platform: Windows ;
Language(s) : C++ ;
I need to drag and drop inside C4D some files and create materials based on them.
I have a SceneLoaderData plugin and I use the Load call to add the materials.
One problem comes when I try to drag and drop multiple files. Even though the Load runs once for each droppped file, the parameter BaseDocument is not the same. Also, it looks like the dropped files are considered whole documents.
The code works correctly if only 1 external file is dropped inside C4D.
I create an empty BaseMaterial with BaseMaterial::Alloc(MY_MATERIAL_PLUGIN) and after filling its parameters, I insert it in the BaseDocument that's given as parameter.
What can I do to consider the dropped files materials and add all of them in the Active Document.
Is it safe to use GetActiveDocument ?
Thank you very much for your time.
On 15/08/2016 at 08:17, xxxxxxxx wrote:
I can only discourage the use of GetActiveDocument() in a SceneLoaderData (like basically in all NodeData derived plugins).
Unfortunately you have run into a limitation of SceneLoaderData plugins. They virtually import scenes into (new) documents, with the exception of being called by the "Merge" command from "File" menu.
As a workaround you could use a dialog and handle drag'n'drop and importing of the files manually (without SceneLoaderData). Then you are free from the above limitation and can load as many dropped files into a single document as you like.