Jump to content
gemini

Event firing when a node is Deleted ( not HDA )

Recommended Posts

Hi,

Can houdini pythyon can solve this: I have an object (rop network in obj) when is deleted I want to run a py script. 

Thanks in advance !

Sz

Share this post


Link to post
Share on other sites

You can right click on the rop network, go on type properties -> scripts and on Event Handler (at the bottom) you can put "on deleted" in the dropdown menu. Then on the right panel, in Edit as, you can change from Hscript to Python and write your script.

When you delete the node, this script will be executed. 

Share this post


Link to post
Share on other sites

Thanks, but I don't think it's a good sollution to override the factory default otls definition.  It causes a lot of error.

Maybe has other way. Any Idea ?

Sz

Share this post


Link to post
Share on other sites

You are right gemini, that's not a good idea.

 

This is interesting. The documentation says that if is used "addEventCallback(event_types, callback) "  is valid just on the current instance and session of Houdini. What if I want to make it valid for this particular instance but also for every time I open Houdini again?

 

Share this post


Link to post
Share on other sites

Thanks, when the hip is opened a script should init the node events..

 

But I can't get it work now.  My simple example:

n = hou.node('/obj/null1')

n.addEventCallback( hou.nodeEventType.BeingDeleted , hou.session.a())

 

It writes:

TypeError: in method 'Node_addEventCallback', argument 2 of type 'std::vector<HOM_En
umValue *,std::allocator<HOM_EnumValue * > > const &'

 

Any Idea ?

 

 

Share this post


Link to post
Share on other sites

The problem is that it expects the first arg to be an iterable of enums, not just a single:

n.addEventCallback( [hou.nodeEventType.BeingDeleted] , hou.session.a())

 

Share this post


Link to post
Share on other sites

Thanks, I get closer..

I check: Delete the Node.

I have a strange error.. While run event callback:

TypeError: 'NoneType' object is not callable

 

My Session code:

def a():
    print 1
    

DOes it causes the deleted node ? Any Idea? THX

Share this post


Link to post
Share on other sites

You don't need to call your function inside your event callback

n.addEventCallback( [hou.nodeEventType.BeingDeleted] , hou.session.a)

Also you might need to add **kwargs arguments to your function depending on the event type as specified in the documentation.

Please refer the example given here: http://www.sidefx.com/docs/houdini/hom/hou/Node.html#addEventCallback

Hope it helps :)

Cheers

-J

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×