gemini Posted October 10, 2018 Share Posted October 10, 2018 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 Quote Link to comment Share on other sites More sharing options...
Andrea Posted October 10, 2018 Share Posted October 10, 2018 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. Quote Link to comment Share on other sites More sharing options...
gemini Posted October 11, 2018 Author Share Posted October 11, 2018 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 Quote Link to comment Share on other sites More sharing options...
vtrvtr Posted October 11, 2018 Share Posted October 11, 2018 You can have events from nodes by type of individually without editing any defaults. Check http://www.sidefx.com/docs/houdini/hom/locations.html "Node event handler files" section Quote Link to comment Share on other sites More sharing options...
Andrea Posted October 11, 2018 Share Posted October 11, 2018 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? Quote Link to comment Share on other sites More sharing options...
gemini Posted October 12, 2018 Author Share Posted October 12, 2018 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 ? Quote Link to comment Share on other sites More sharing options...
graham Posted October 12, 2018 Share Posted October 12, 2018 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()) Quote Link to comment Share on other sites More sharing options...
gemini Posted October 12, 2018 Author Share Posted October 12, 2018 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 Quote Link to comment Share on other sites More sharing options...
animknight Posted October 15, 2018 Share Posted October 15, 2018 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 Quote Link to comment Share on other sites More sharing options...
gemini Posted October 18, 2018 Author Share Posted October 18, 2018 (edited) Thanks! Edited October 18, 2018 by gemini Quote Link to comment Share on other sites More sharing options...
Andr1 Posted March 8, 2019 Share Posted March 8, 2019 (edited) 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 March 9, 2019 by Andr1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.