Can I bypass calling the material manager when create new materials?
-
Hi everyone,
Some descriptions:
I have a noising problem about the material manager, now it had a hided button for the material manager, I always create materials with my tools and want to leave the manager out, when I create 1st material it will silence the material manager but when a create the 2rd material it will popup.
Problem:
What will cause this happend in the manager, maybe the
SetActiveMateria
l orSetBit
function , can I force silence the manager until I hit the button?
(I need set active material to open certain node editor for the material)Cheers~
-
Hello @dunhou,
Thank you for reaching out to us. I am struggling here a bit with understanding what you mean by:
I have a noising problem about the material manager, now it had a hided button for the material manager, I always create materials with my tools and want to leave the manager out, when I create 1st material it will silence the material manager but when a create the 2rd material it will popup.
What do you mean by 'noising problem about the material manager' and 'create 1st material it will silence the material manager but when a create the 2rd material it will popup' ? What does 'noising/silence' mean in this context for you?
Cheers,
Ferdinand -
@ferdinand Hey, Sorry to a bad description, here is a gif which has a better information.
1:
I create a material and auto apply to the cube, the material manager didn't popup (which I mean "silence" here )
2:
But when I create another material, the manager will popup immediately, can I bypass this and only popup the material manager only I hit the mat-ball icon?
( Or , which functions will take this behaviour and can I bypass the step )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 theNode Editor
for certain renderer or rules for the function, it is also way long for the forum, I will send you a copy if it is needed.
Cheers~
-
Hey @dunhou,
Please excuse me, but I am still struggling with understanding what is going on here. This could be simply because I am not the most proficient Cinema 4D user and are not aware of all end-user functionalities.
The context-menu you are opening in your screen cast (thanks for sharing it, always helps a lot), is that a modified or built-in context menu of Cinema 4D or is that a plugin of yours? I cannot find anything in
2023.1.3
what would exactly resemble it.When I open the "standard" context menu for an object in the object manager, I cannot reproduce your behaviour.
In case it is your code which is running there, and you simply want know if the Material Manager is already open, your should check out c4d.IsCommandChecked(id), when it returns
True
, then the command is "checked", which in case of the foldable managers as the Asset Browser, Material Manager, Coordinate Manager, etc., means that they are unfolded. When you then invokeCallCommand
on an already opened manager, it will close the manager. I used this for example in the Python Asset API examples to open the Asset Browser when it is not already open.If that is not the problem, I will have to ask for more information:
- Which exact version are you using?
2023.1.3
? - Is the context menu you show part of a default installation?
- If so, how do you invoke it?
- Anything else noteworthy? Because as you see from my screen cast, just creating two node materials from Object Manager does not result in the same behavior.
When this is about native features (and not a plugin or script), this would be also more a bug report for our Support Center.
Cheers,
Ferdinand - Which exact version are you using?
-
Hey@ferdinand
No, it is not a build-in function, it is my plugin that I used all day, You can have a brief look here .it support main render engine in Cinema (Octane/Redshift/Arnold)( it seems I do a good job to fake it like original )actually,I checked the
c4d.IsCommandChecked(id)
,but it has a problem to me:
If I check this in my code, when I create a material with my plugin, the material manager will closed, but I just don't want to tigger it like the gif you shown with the bulid-in function, so that I can decide open the material manager I wanted to.So I don't know which command will trigger the
opened
the material manager.
Hope this time will be clear -
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 withCallCommand
or places where an ID determined at runtime is invoked (silly example :CallCommand(random.randint(1000, 1000000))
) Then run your plugin again. When you see12159
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