How to Modify Button Parameters?
-
I’m working on a Cinema 4D + Octane Render project and need help modifying the "Import Type" button parameters of an ImageTexture node. Specifically, I want to automate or script the selection of different import types , but I can’t figure out how to access or modify this button’s settings through the Python.
I understand that Octane-related topics may not be suitable for this forum, but I've been struggling with this issue for a long time and really need help.
This is my code, but it's not working as expected.
import c4d def main(): mat = doc.GetActiveMaterial() shader = mat.GetFirstShader() ImportType = c4d.DescID(c4d.DescLevel(1139, c4d.DTYPE_BUTTON, 0)) importValue = shader.GetParameter(ImportType, c4d.DESCFLAGS_GET_0) shader.SetParameter(ImportType, 2, c4d.DESCFLAGS_SET_0) c4d.EventAdd() if __name__ == '__main__': main()
-
Hey @Ross,
Thank you for reaching out to us. You are right, we cannot support third party APIs, but questions about our API do not automatically become moot or out of scope of support, just because they happen in the context of a plugin. We will of course still answer such questions. We will just never write code for a third-party API or test user code that requires a plugin.
Your question '[I] need help modifying the "Import Type" button parameters of an ImageTexture node' is however ambiguous. A parameter is Cinema 4D slang for an element in a description, one of the ways of how Cinema 4D defines UIs. This includes things that users would naturally call a parameter such as a textbox holding a string, a number edit holding a float, or a combo box holding a selection, i.e., things that hold a value. But it also includes things that are just part of the UI of a node that cannot hold a value, e.g., a group, a separator, or a button.
- When someone talks about 'modifying' a parameter I would usually assume that they talk about changing the description of a node, specifically at that parameter. E.g., changing the label of a button, adding or removing elements to/from a drop down, disabling an element, etc. You can only do this for nodes you own, i.e., implement yourself. You cannot change the UI of alien elements, because for you their description is read only.
- But I assume you are actually talking here about getting or setting the parameter of an element, e.g., set a float slider to the value '4.13'.
What gets a bit in the way here in your case, is that Cinema 4D summarizes everything under the label of paramater, even things that do not naturally have a value which could be gotten or set. So, I assume you want to press this button, for that you have two options:
- Call c4d.CallButton
- Send the message c4d.MSG_DESCRIPTION_COMMAND
Please note that both approaches are restricted to being called from the main thread only when the scene element upon which they are called is part of a loaded scene. E.g., calling one of them on a node in the active document from outside of the main thread: forbidden. Calling them from inside a
GetVirtualObjects
(or any other off-main thread context) on a scene element in a dummy document which has been constructed just for this purpose and is not loaded by Cinema 4D: absolutely fine.Cheers,
Ferdinand