Use GeListNode.GetNBit(bit) to access the bitfield for the flags. Then check for the bit NBIT_OM1_FOLD, NBIT_OM2_FOLD, NBIT_OM3_FOLD, NBIT_OM4_FOLD, depending on which object manager you're in.
Note that there are 4 possible object managers, and the opening status can be different for each, so there are 4 different bits to control the status. The difficulty here is that C4D's API does not tell you what OM you're currently in (C4D does not provide a lot of control of the windows...), so worst case you need to have 4 different scripts if you are regularly working with all OMs. (If you only have the first OM open, the point is moot.)
(I normally don't link back to my own page but incidentally my Python-in-C4D course is in the rough vicinity of handling the bitsets, so you may want to check out https://www.patreon.com/cairyn if you're interested in that kind of thing.)
but that's really my intention, delete items from the scene as soon as their hierarchy is unfolded
@Cairyn said in how is it possible to check if the object is being "opened"? with python:
ohh! this worked thanks!
but partially ... I would need something to keep checking all the time
@pyxelrigger I'm not sure what you mean by "all the time". What's the execution context? A script is generally only executed once, precisely when the user calls it. A Python tag is executed every time when the object tree is evaluated.
You can build a plugin that reacts to messages in the system, and filter those messages, but in general I really don't recommend messing with the execution timepoints and contexts unless it's really really important.
So, what is the idea, why do you need to check "all the time"?
Hi @pyxelrigger, thanks for reaching out us.
With regard to your question, I recommend having a look at the GeListNode Manual - it's C++ doc but it's worthy to be read -.
With regard to your second post instead, I warmly invite you to be more explicative providing a better explanation on you're looking for.
I need to check if it is being opened, and not if it is open
Hi @pyxelrigger thanks for following up.
With regard to be informed in the console about a hierarchy in the Object Manager being folder or unfolded, there's no performance-penalty-free solution to be implemented. The only and heavily performance-affecting workaround, would be to monitor each entry of the object manager and check its NBit but, as you can imagine, it's cumbersome and could work only with a very limited number of entries in the scene.
At the same time, I wonder what's the final scope of checking this folded state, cause likely by looking at the problem from a different direction we might come with different, and more effective, solutions. Can you elaborate more on what's the final goal?
basically this is the algorithm that i need
Hi @pyxelrigger thanks for the follow-up but actually it doesn't answer to my question of clarifying the final goal.
Explaining a bit better your intent will help us to be more effective in helping, because looking at the code it seems like that you expect to delete items from the scene as soon as their hierarchy is unfolded that's weird without a proper context.
Well @pyxelrigger thanks for clarifying the final scope.
Since, as already stated, folding or unfolding a scene entry doesn't generate any valuable message to be intercepted, the sole - brute force - hack you might try to implement in Python would be to implement a MessageData plugin which constantly checks for the folded/unfolded state of the entries in the scene and eventually delete the unfolded one.
This approach carries strong performances penalties to the whole Cinema 4D UI because you need to constantly traverse the scene and depending on the scene size this could strongly affect Cinema performances.
If there are no further question please mark the thread as solved.