@m_adam said in Python Tags - Shouldn't really they can change the scene?:
Hi @SolarPH when you say -- Import Rig Parts > Arrange Parts > Modify UserData > Delete Importer --
it looks like these steps can come from a series of buttons pressed.
It can be, but I planned it to be all automated using a series of codes.
If you are doing all of that in the Execute method, then it's not ok and it could affect the c4d stability (we do have crash reports about that).
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.
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.
if you are in the main thread you are safe to do whatever you want
Also, According to the online manual about python codes for cinema4d (official documentation), for example, I do
c4d.documents.MergeDocument(doc,Path,c4d.SCENEFILTER_OBJECTS|c4d.SCENEFILTER_MATERIALS,None)
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)
@PluginStudent said in Python Tags - Shouldn't really they can change the scene?:
The purpose of a Python Tag is to define the behavior of existing objects in the scene, similar to an XPRESSO tag. The Python Tag is part of the scene execution pipeline, and you must not edit scene from withing the scene execution.
If you want to edit the scene (insert stuff etc.) you must do this solely from the main thread.
ALSO I just noticed... I meant Python Node, not Python Tag. lemme correct that one....