Jump to content

Executing Callback on Multi-Selected OTLs


fxrod

Recommended Posts

Hey Guys:

I have an otl with a button and a callback script. When I select multiple instances of the tool and hit the button, it executes the callback as many times as there are instances. In other words, if my button prints "Hello World" and I select 10 instances, then hit the button on one of the instances, "Hello World" prints 10 times.

Is there any way to have it execute the callback only once from the button on the otl?

Thanks much in advance.

Link to comment
Share on other sites

  • 1 month later...

I would do something like:

in your callback script first return a list of selected nodes using

selectedNodes = hou.selectedNodes()

filter this selection to only count your otl nodes (in case you have other nodetypes selected) using

filteredSelection = [x for x in selectedNodes if x.type().name() == 'myOtlTypeName']

if your node is not the first node in this list, do not fire the callback

as a bonus this will make your otl aware of other otl instances

does that help?

Edited by glassman3d
Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...