Parameter set in init of MaterialData plugin

On 03/09/2015 at 13:20, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   R16 
Platform:   Windows  ;   
Language(s) :     C++  ;

Hello !

I have created a Custom GUI Data plugin along with an iCustom class and a UserArea.
The value that is set to and get from the user area is LONG.

So, in the resource file i use:

In the material plugin init function i set the value of MY_PARAMETER to 9 using the GetDataInstance of the node.
When the initGLImage is called, i get the value of MY_PARAMETER using again the data, but this time it has value of 1.

I have checked these values in the very first call of Init and InitGLImage
Is there anything that is called between and affects the value of MY_PARAMETER?

Thank you for your time.

On 03/09/2015 at 14:58, xxxxxxxx wrote:

Another thing i forgot to mention is that in the first call of SetData of the iCustomGui, the Long value of 
tristate.GetValue().GetLong() is always 1.

On 04/09/2015 at 01:19, xxxxxxxx wrote:


does this also happen when you don't use your custom GUI for that parameter or does it only happen in that case?

Best wishes,

On 04/09/2015 at 12:11, xxxxxxxx wrote:

this happens here too!! in my custom data type with tri state, in a material data plugin, there is Init(), SetDParameter() and GetDParameter(),  SetDParameter() is overriding the custom data value before Init(), didn't find a solution yet, help please Sebastian.

On 05/09/2015 at 04:28, xxxxxxxx wrote:


Here is a more detailed case that explains where the problem resides.

Lets say i have 2 versions of a Material Data plugin.
First i use the version 1 which inits MY_PARAMETER to 3.
I run my project,  save it and then exit c4d.
Then, I switch to version 2 of Material Data plugin which inits the same param to 9.
Bu this param is already set to 3 in project.
So after init in version 2, the param is read from the project file (value 3).

My question was why the parameter has value where nowhere i set it in the code, so this solves it.
Thank you.

On 07/09/2015 at 00:01, xxxxxxxx wrote:


what do you mean with "2 versions of a Material Data plugin"? Two instances of the same class or two different plugin classes? And also, does this behavior only happen with your custom GUI or also without it?

Best wishes,

On 07/09/2015 at 00:37, xxxxxxxx wrote:


By saying 2 versions of material Data Plugin i mean 2 implementation versions of this plugin.
I use #define _RUN_VERSION_1_ and _RUN_VERSION_2_ to define which one to run each time.

The reason why i need to do this is because i use different interfaces. Different interfaces equals to different parameters. That means i also use 2 different versions of .res files.

My mistake was that in version 1 i was setting parameters that didn't actually exist in that implementation (or lets say in the corresponding *.res file).

Nevertheless in version 2 they were retrieved from the project file and used after the initialization.

Also this issue appears even without my custom gui .


On 07/09/2015 at 09:05, xxxxxxxx wrote:


to just to understand what you are saying: you set different #defines, you recompile your plugin and then test it?

Do the different versions of your plugin also use different plugin IDs? It not, they are the same plugin for Cinema.

Best wishes,

On 08/09/2015 at 00:29, xxxxxxxx wrote:

Hello !

Originally posted by xxxxxxxx

to just to understand what you are saying: you set different #defines, you recompile your plugin and then test it?


Also, the different versions don't use different Plugin IDs.

My problem is that by mistake, in a previous version of Material Data plugin, 
i have used data->setLong(2100, 5) even though parameter 2100 didn't exist.

Now (version 2) i have to use 2100 in a totally different case. But the parameter 2100 already exists in user projects with value 5. That means i cannot initialize it properly in Init(...), since the data from project file are retrieved.

Here is what can solve my problem:

  1. find a way to totally clear the parameter 2100 in a project.
  2. Set the value of parameter 2100 in Init, even though it already has a value in the project file.

Thank you !

On 08/09/2015 at 09:42, xxxxxxxx wrote:


So it seems you don't have a problem with your plugin or your code but with a scene? You can set the version of a plugin in its Register() function, for example in RegisterMaterialPlugin(). This value is useful if you implement Read() and Write().

If you want to "delete" a parameter you can try to create some script that accesses the material's BaseContainer in your scene and removes an entry using RemoveData().

Best wishes,

On 08/09/2015 at 10:39, xxxxxxxx wrote:


Can i use the RemoveData in the Read() method of the material (no matter the version)?

Bool Read (GeListNode* node, HyperFile* hf, Int32 level){
	BaseContainer* data = ((BaseList2D* )node)->GetDataInstance();
	data->RemoveData(2100);// or data->setLong(2100, 8);
	return NodeData::(node, hf, level);

Thank You.

On 09/09/2015 at 02:08, xxxxxxxx wrote:


it seems that this could work. But I'm not sure if it could have side effects so please test carefully.

Best wishes,