Jump to content

Event firing when a node is Deleted ( not HDA )


gemini

Recommended Posts

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. 

Link to comment
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?

 

Link to comment
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 ?

 

 

Link to comment
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

Link to comment
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

Link to comment
Share on other sites

  • 4 months later...
On 10/11/2018 at 5:57 PM, Andrea said:

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?

 

I would like to know as well. It seems that for a Digital Asset instance you should register the event callback inside the OnLoaded event handler script. Am I right?

Indeed, I'm currently registering an event callback (flag change) for a Digital Asset inside an onLoaded script.

My issue is that the callback function is being run twice. Do you happen to know the reason?
This is the code I'm using inside the onLoaded script:

node = hou.node("/obj/geo1/flagchanged1")
def flagChanged(event_type, **kwargs):
    if node.isGenericFlagSet(hou.nodeFlag.Display) == 1:
        print("display flag is set")


node.addEventCallback((hou.nodeEventType.FlagChanged,), flagChanged)

---------------------------------

---------------------------------

UPDATE. For anybody that might face the same issue in the future:

I believe I understand what's going on: it runs two times because when you change the Display Flag on a node with the left mouse button you would automatically set the render flag as well. So you are actually setting two flags with one click, that's why the event .FlagChanged is being triggered 2 times.

Indeed, If you try to use the combination alt+LMB to exclusively set the display flag (and leave the render flag in place), the event callback is triggered only 1 time.

I guess that you can't really avoid this behavior and, in order to trigger 1 single event callback when the display flag is changed, you should write some conditional and use some toggle parameter to write to and check against it every time the event callback is triggered.

-------------------------------

 

 

Q_onLoaded_checkFlag.hiplc

Edited by Andr1
Link to comment
Share on other sites

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...