How to do something when the user exits viewer state?

   775   1   1
User Avatar
Member
696 posts
Joined: 8月 2019
オンライン
For example, say if I have this shelf tool script:

import soptoolutils

soptoolutils.customStateTool(kwargs, 'polyextrude::1.0')
print(1)

The print(1)part will run immediately when the shelf tool is called. How could I make it run after the user exits PolyExtrude's viewer state? (Like putting it in some kind of asynchronous callback?)
User Avatar
Member
696 posts
Joined: 8月 2019
オンライン
Well, no answer... perhaps I'll need to give a more practical use case.

For example, I'd like to create an Edit SOP, get into its state, and automatically set updatenmlsparm:

import soptoolutils

node = soptoolutils.customStateTool(kwargs, 'edit')
node.parm("updatenmls").set(False)

However, it doesn't work! nodeis Nonehere. It makes sense because the Edit SOP node is only created after the user exits the custom state. But how could I run node.parm("updatenmls").set(False)after it's created?


Edit:

I've noticed that for generic tool (non-custom state tool), I can set parms like this:

kwargs['parms'] = {
    'updatenmls': False,
    'xformspace': 1,
}
node = soptoolutils.genericTool(kwargs, 'edit', isreusable=True)

This solves the above particular use case, but I still don't know how to "do something after the user exits a custom state" in general.
Edited by raincole - 2025年5月5日 18:05:58
  • Quick Links