Jump to content


Executing Callback on Multi-Selected OTLs


  • Please log in to reply
2 replies to this topic

#1 fxrod

fxrod

    Peon

  • Members
  • Pip
  • 73 posts
  • Joined: 12-January 07
  • Location:San Francisco
  • Name:Francisco Rodriguez

Posted 20 April 2012 - 09:44 PM

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.
----------------------------------
Francisco Xavier Rodriguez (fxrod)
ILM FX TD

#2 glassman3d

glassman3d

    Peon

  • Members
  • Pip
  • 12 posts
  • Joined: 20-August 10
  • Location:London
  • Name:Sam Swift-Glasman

Posted 24 May 2012 - 01:37 AM

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, 24 May 2012 - 01:40 AM.


#3 fxrod

fxrod

    Peon

  • Members
  • Pip
  • 73 posts
  • Joined: 12-January 07
  • Location:San Francisco
  • Name:Francisco Rodriguez

Posted 03 June 2012 - 04:10 PM

Thanks! I'm going to look into your suggestion and see how it goes. Cheers!
----------------------------------
Francisco Xavier Rodriguez (fxrod)
ILM FX TD




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users