[PYTHON] How to properly set the toggle of viewport solo
-
Howdy,
I was wondering how I could go about enabling/disabling the viewport solo through python(not through CallCommand). I don't see it as a BIT or NBIT to change, but it is also not a tool or modeling command as far as I can tell. Searching the API for VIEWPORT_SOLO_MODE doesn't turn anything up. I was wanting to be able to set and toggle it and the other solo options like Hierarchy etc. Does anyone have any info on how to work with that?
-
Hello @BretBays,
Thank you for reaching out to us. Object soloing is based on NBIT_EHIDE which will hide an object in the viewport. So, if you would want to replicate the soloing functionality, you would have to traverse all objects to set
NBIT_EHIDE
on all of them except for the objects which areBIT_ACTIVE
, i.e., selected.But I do not really understand why you do not want to use
CallCommand
? Is it because of threading restrictions? If you think you can circumvent this by doing it yourself, I must strongly advise against changing the flagNBIT_EHIDE
from a non-main-thread-thread. While setting flags from a non-main-thread-thread in general is allowed, settingNBIT_EHIDE
will not just ignore objects when drawing but mute their caches. When you change this in the middle of an update cycle, you are bound to run into problems. A lot of things in the scene processing is checking forNBIT_EHIDE
.When returning a cache in an object plugin or a Python Generator object, you can hide parts of your cache with
NBIT_EHIDE
(and the other hiding flags which do exist). The only other valid scenario is settingNBIT_EHIDE
from the main thread or using theCallCommand
from there.Cheers,
Ferdinand -
In the past I have refrained from CallCommands and CallButtons because they used to add to the undo queue or did. But I suppose in this instance I can just do it for thise purpose.