So I am in the process of learning how Python and scripting in C4D works.
Working with this interesting tutorial series, but have falled down at the first hurdle: nothing seems to run from the expression editor.
I have run scripts successfully from the Script Manager, but nothing so far from the Expression Editor.
All I have is:
a cube with a python tag
The following code:
#Welcome to the world of Python
It runs fine in the command line and in the script manager, but not the expression editor looking at the python tag on the cube.
Any suggestions where I may have gone wrong?
R21.207 (Build RB303831)
You may want to make a viewport visible.
Apparently, your viewport is somewhere in the background. Under those circumstances, the evaluation of the object tree seems to skip a beat... C4D seems to be thinking "hey, if you don't wanna see my results, I won't bother doing anything"
I verified this on my system - no viewport, no output!
(Don't ask me why Maxon is doing that, I don't have access to the inner code...)
The code actually works fine for me being in a Python Tag on a Cube. When the scene is refreshed, the tag is executed, and the console shows the version line.
What's happening (or not happening) on your side? Remember that you need to trigger the execution of the tag by doing something in the scene like selecting or forwarding the timeline; the execution context is different from the script manager (where you explicitly trigger the execution by clicking "Execute"). With a tag, the execution is bound to the evaluation of the scene tree.
Above is a quick screen grab of me trying to run it.
Interesting - not even pressing Execute in the Expression Editor creates an output if the viewport is not visible. Duh, I would have expected that. Maybe it's an actual bug.
Bringing the viewport into focus worked... wow, I had a feeling it was something simple like that!