Hello @dunhou,
ah that was the critical bit of information for me, that is you plugin at work there 😄 Well, as always without code it is hard to say what is going wrong there.
the main code about this function is like :
SetBit() doc.InsertMaterial() c4d.CallCommand(12252) # Render Materials doc.GetActiveMaterial() textag.SetMaterial() and some undo and call the Node Editor for certain renderer or rules for the function ...
Out of this selection, I would put my money on CallCommand and undo handling. Setting bits and calling the mentioned methods are far less likely candidates. But that is pure guess work.
actually, I checked the c4d.IsCommandChecked(id)
The first thing I would do, is search for the command ID of the Material Manager (12159) in your code and add a print statement to each place where either this command ID is invoked with CallCommand or places where an ID determined at runtime is invoked (silly example : CallCommand(random.randint(1000, 1000000))) Then run your plugin again. When you see 12159 being printed when the undesired behaviour happens, you know it must be your plugin which misfiring. When not, it might be a bug in Cinama 4D or one of its APIs.
Cheers,
Ferdinand