We can update the Python API to align with the C++API
-
Hi SDK team,
I notice that webview in python only have few api but without functions such as
ExecuteJavascriptorSetWebMessageCallbackand theSetURLCallbackis diffrent form C++, at least that's what the document says.Do we have plans to add corresponding functions in Python APIs?
Or, on the existing basis, how do you suggest implementing data processing from C4D ->web ->C4D?e.g. Read the selected object, click the button in the webview, and rename the selected object.Cheers~
DunHou -
Hey @Dunhou,
Thank you for reaching out to us. We agree that this would be desirable. These methods are actually already wrapped but we hide them for now in the Python SDK. Find the reasons below.
ExecuteJavascript: I just did remove the bindings of the Python API for that method in the current beta and also switched the C++ method to internal. The reason for that decision was is that we have security concerns about attackers being able to execute arbitrary JS in a web browser opened in Cinema 4D.SetWebMessageCallback: This is intended solution, i.e., the JS you want to execute must be already embedded into the HTML which is running in the HtmlView. On Windows/WebView2 it uses web messages, on MacOS/WebKit a custom solution emulating them. AndSetURLCallbackis then the way to get data back from the JS VM.- For 2026.1 I already wrote examples for these methods, but on the last meters we discovered that something not only broke the Python bindings but the whole "execute JS" in the WebView2/WebKit bindings.
My last info is that something broke there due to a project update, and that the two devs involved in it will have a look. I'll give them another bump and report here if there are any updates.
Cheers,
Ferdinand