InsertMaterial in ObjectData plugin [SOLVED]
-
On 07/05/2015 at 10:05, xxxxxxxx wrote:
Hi Casimir,
can you give us an example of the code you used in MSG_DESCRIPTION_POSTSETPARAMETER? -
On 08/05/2015 at 01:18, xxxxxxxx wrote:
Hi Andreas,
I've used this code:
BaseMaterial* myMaterial = doc->SearchMaterial("My_Material"); if (!myMaterial) return nullptr; BaseContainer* myMaterialData = myMaterial->GetDataInstance(); if (!myMaterialData) return nullptr; myMaterialData->SetParameter(MATERIAL_COLOR_COLOR, bc->GetData(MYMATERIAL_DIFFUSE_COLOR)); myMaterial->Update(true, true);
I also recently found out that I do not need to do this inside Message. I can simply use this in GetVirtualObjects and everything works fine.
Still thanks for your help and time!
Greetings,
Casimir Smets -
On 08/05/2015 at 01:22, xxxxxxxx wrote:
1. Make sure this does not result in recursion (due to the SetParameter call)
2. You shouldn't change the active scene from within GetVirtualObjects. See threading information in the docs. -
On 08/05/2015 at 02:40, xxxxxxxx wrote:
Hi Katachi,
What do you mean by recursion? I've translated it and I know it means repetition, but what repetition?
And secondly, I know I shouldn't change materials in a threaded-function, but because it didn't work in ANY message, I had to do it somewhere else. Besides, it seems to have no problem with it.. although it could give a bigger problem that I do not know about.
If you would know another way how I could do this, I would greatly appreciate it!
Thanks for your help and time!
Greetings,
Casimir Smets -
On 08/05/2015 at 03:50, xxxxxxxx wrote:
1. MSG_DESCRIPTION_POSTSETPARAMETER is triggered after SetParameter has been called (hence its name). As you use SetParameter it may result in recursion (and maybe that's why the crash happens? At which code line does the crash exactly happen? You should debug your code.). It's worth checking out VALIDATE message for example or other description messages.
2. Well, it may crash unexpectedly depending on threading. That's why it is so unsafe.
-
On 08/05/2015 at 05:04, xxxxxxxx wrote:
Hi Katachi,
Thank you very much for your input!
I will definately look into it!
And... I have tried it in every MSG, even in the ones I was sure it would not workThanks for your help and time!
Greetings,
Casimir Smets -
On 11/06/2015 at 01:32, xxxxxxxx wrote:
Hi,
For the people wondering, the final solution can be found here:
https://developers.maxon.net/forum/topic/8792/11595_change-material-color-in-objectdata-pluginsolvedWith kind regards,
Casimir Smets