Stalkerx777 Posted October 14, 2010 Share Posted October 14, 2010 Hi. I'm trying to initialize parameter in my asset with value,that i'm trying to get from inside asset itself. It's like setting default value, but dynamically, based on calculations inside my operator. In Operator Type Properties, Scripts tab, i have PythonModule event, with something like this(abs path, just for debugging): def matchPivot(this): pathToNode = "/obj/torus_object1/" + this.name() + "/pivot_parm" node = hou.node(pathToNode) pivotValues = node.parm('pivx').eval() print pivotValues Next i have added "OnCreated" event, and call my function from it: this = kwargs['node'] this.hdaModule().matchPivot(this) The problem is that my function,seems like, evaluating before cooking my operator.So, matchPivot() always returns 0. Parameter "pivx" has expressions, and normally works just fine,after my operator was created, but my function returns 0. Tell me please, where i'm wrong ? Is it possible to get some values from inside asset. Sorry for my "crooked" english Quote Link to comment Share on other sites More sharing options...
graham Posted October 15, 2010 Share Posted October 15, 2010 By nature the OnCreated event happens right as the node is created, before it cooks. What you should be able to do is in the OnCreated script, force the node to cook right then (hou.Node.cook()), as opposed to letting Houdini automatically cook the node afterwards. this = kwargs["node"] this.cook(True) this.hm().matchPivot(this) Quote Link to comment Share on other sites More sharing options...
Stalkerx777 Posted October 15, 2010 Author Share Posted October 15, 2010 By nature the OnCreated event happens right as the node is created, before it cooks. What you should be able to do is in the OnCreated script, force the node to cook right then (hou.Node.cook()), as opposed to letting Houdini automatically cook the node afterwards. this = kwargs["node"] this.cook(True) this.hm().matchPivot(this) Thx graham! Unfortunately, that gives me an error Traceback (most recent call last): File "opdef:/Sop/polyExtract?OnCreated", line 2, in <module> File "c:/Houdini/11.0.528/houdini/python2.6libs\hou.py", line 5593, in cook return _hou.Node_cook(*args, **kwargs) OperationFailed: The attempted operation failed. Error while cooking. Then, i manged it to work, but with OnInputChange event, it works fine (with code in my first post, without forcing recooking). To clarify: I have one more event - PreFirstCreate , in which i create selector, to make selection of prims. And this selector is in HScript. This selector is responsible for wiring my operator, right after i make selection.Then, of course, input changes, and event OnInputChange works fine. And i have one more problem, i'll deal with that later. Thanks! Quote Link to comment Share on other sites More sharing options...
Stalkerx777 Posted October 18, 2010 Author Share Posted October 18, 2010 It's me again Please help me with a following problem: As i wrote earlier, i have PreFirstCreate event, in HScript: omsbind -t sop polyExtract:group prims "Poly selector" "This is HScript event!" 0 1 face 0 "" 0 Ok, it works. Then i decided, to do it in Python: kwargs['type'].addSelector("polySelector","prims", prompt="This is Python event!") And here interesting thing happens Even if change this event to from HScript to Python, when i use my tool in viewport, it still executes HScript event! Of course i'm saving all changes.I'm also doing File -> Refresh Asset Libraries. The only thing that helped me - recreate asset, without PreFirstCreate event. And vice versa, if PreFirstCreate event was in Python, and i change it to HScript, it will still call Python, even if i delete this event! Any Ideas??? Quote Link to comment Share on other sites More sharing options...
domsewell Posted April 21, 2020 Share Posted April 21, 2020 (edited) @Stalkerx777 Hi there, apologies on bringing up very old thread im struggling to find information on a problem i have and this thread seems the closest and i assumed maybe you could help me out. Im creating multiple nodes of a digital asset at obj level and using a callback script on a parameter on these assets. However, each one may have different parameter values and thus in the callback script i need to reference the name of the specific asset placed, for example calculator1, calculator2 etc. ive tried using hou.pwd in my python module however that just returns the root directory '/'. Using kwargs ['node'] in the on created event handler seems to return the name im looking for. I've then called a function in my python module that takes the name found in the on created handler and returns it. Im trying to then access this name in other functions held within my python module but i dont think im returning the value correctly to be used? Edited April 21, 2020 by domsewell progress with issue at hand 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.