An express tag is a tag, and it evaluation takes place as any other tag, meaning it has the same limitation as a Python Scripting Tag.
@SolarPH said in Python NODES - Shouldn't really they can change the scene?:
I've set all of those outside Execute method to ensure that it wouldn't loop infinitely. I often connect it to an if/else statement (connected to a boolean/integer switch that switches itself off after the first cycle) to ensure that it wouldn't make Cinema4D crash.
I'm not sure to follow you here but since you modify the scene content while the scene execution (aka xpresso execution) then it can affect the stability, and it does not matter if it's executed once or 100 times, so you may run into a conflict with another part of the scene while this other part is accessed by something else, and you have a crash.
make sure to call StopAllThread, but you can even call EventAdd
I actually haven't tested StopAllThread line yet, but I can already use EventAdd() after any commands that changes the scene in terms of heirarchy and inserted objects. I haven't really tested doing a delete command, but I have some ways to let the code know what to delete after the cycle. Utilizng ports as a way to actually pass the correct object data on the code makes it easier for me to execute this kinds of codes on my python tags.
I was speaking if you are in the main thread, which is not the case here because you are in a tag execution, so if you call StopAllThread within your thread, your thread will be canceled (due to the nature of python, your python code may execute completely but not the other part of the xpresso evaluation)
Also, According to the online manual about python codes for cinema4d (official documentation), for example, I do
will make it run on Main C4D Thread (i don't actually know if not putting the None at the end of the code makes it run on another thread, but when I tried, it doesn't actually crash C4D since the line only runs once because of the nature of the switch I used)
Passing None in the MergeDocument will not make it run into the main thread, you just pass the thread you are currently in, and it will be this thread that will be tested if you should leave or not, but it does not modify where the code is executed. So calling MergeDocument is not fine because, in the end, you modify the current document especially if there are some materials. And this could make Cinema 4D Crash since a lot of stuff happens during a merge.