cruiserandmax Posted May 10, 2015 Share Posted May 10, 2015 (edited) CORRECTION: I meant to bind a callback to the back-quote '`' key- not tilda! I am trying to setup an HDA that uses a selection pattern for points, similar to the native group SOP. I am storing the selected points as a pattern in a string field (same as the group SOP). And I'd like to implement the ability for the user to use back-quote '`' to restart selecting. So when back-quote is pressed I want to run a callback to read the pattern, and switch into point selection mode with the points selected. The only thing I can't figure out is how to bind a callback to that event of pressing back-quote... Edited May 10, 2015 by cruiserandmax Quote Link to comment Share on other sites More sharing options...
anim Posted May 10, 2015 Share Posted May 10, 2015 (edited) not sure about `, but since 14 there is new (less confusing way) to re-select geometry you can notice that many nodes have little arrow icon on the right side of the group field that's an action button that can be used to execute any python script, and in case of those group fields it's being used to re-select geometry you can add Action Button to any parm, just by editing parameter interface and type script to Action Button tab for your needs it may look like this: import soputils kwargs['geometrytype'] = hou.geometryType.Points kwargs['inputindex'] = 0 soputils.selectGroupParm(kwargs) Edited May 10, 2015 by anim Quote Link to comment Share on other sites More sharing options...
sadhu Posted May 10, 2015 Share Posted May 10, 2015 Hello, I am trying something similar but don't know much about python. I have created a digital asset which contains group sop. 'pattern' parameter on this group node I have promoted to ui of digital asset. What I want is whenever this digital asset is laid down user should be able to select polygons in the scene viewport and selected polygons should get added in the pattern parameter on digital asset so it creates polygon group out of that selection and digital asset works only on these polygon. Further user should be able to re select the polygons if user wishes so. Upon searching I came across similar questions but could not implement the solutions provided . It seems I have to use python / kwargs / callback script but have no clue how to use it. Following is my feeble attempt. I have added this code in script section of the digital asset. Is there any tutorial available on kwargs / callback script ? import toolutils viewer = toolutils.sceneViewer() selection = viewer.selectGeometry() list = selection.mergedSelectionString() //print list //import hou //node = kwargs['node'] //grpnode = node.path()+"./group1" //grpnode.parm("pattern").set(list) //b = grpnode.parm("pattern") //print grpnode //print b Thanks Quote Link to comment Share on other sites More sharing options...
edward Posted May 10, 2015 Share Posted May 10, 2015 eg. http://forums.odforce.net/topic/20650-selector-behaviour/ Quote Link to comment Share on other sites More sharing options...
cruiserandmax Posted May 11, 2015 Author Share Posted May 11, 2015 Thanks for the suggestions. So far I am able to add something like the following to a PreFirstCreate script on my HDA: kwargs['type'].addSelector(name="foo", selector_type="points", prompt="sel points to foo on and hit ENTER") Then if I create and instance of the node, connect some geometry with points to it's input, then re-enter selection mode (by hitting back quote `)- I can select points, hit ENTER, and then the point pattern is correctly transferred into a string parameter named 'group'. However if I try and select some points in the 3D viewer on some geometry BEFORE my node is created, then hit TAB and pick my HDA name and press ENTER, I get the error: 'NoneType' object has no attribute 'set' Any ideas on how to set it up so I can select points, then TAB-create my node and have the group field automatically populate? Quote Link to comment Share on other sites More sharing options...
edward Posted May 11, 2015 Share Posted May 11, 2015 What's the code where the error is occurring? Quote Link to comment Share on other sites More sharing options...
cruiserandmax Posted May 27, 2015 Author Share Posted May 27, 2015 Sorry for the delay.. the error is: Traceback (most recent call last): File "sop_test", line 3, in <module> File "/usr/houdini/hfs14.0.291/houdini/python2.6libs/toolutils.py", line 926, in new_func return function(*args, **kwargs) File "/usr/houdini/hfs14.0.291/houdini/python2.6libs/soptoolutils.py", line 661, in genericTool exact_node_type = exact_node_type) File "/usr/hfs14.0.291/houdini/python2.6libs/soptoolutils.py", line 536, in genericSopNodeFilterTool force_keep_original_objects) File "/usr/houdini/hfs14.0.291/houdini/python2.6libs/soptoolutils.py", line 261, in initNewSopFilterNode setGroupParmsOnSopNode(newnode, selector, selection) File "/usr/houdini/hfs14.0.291/houdini/python2.6libs/soptoolutils.py", line 178, in setGroupParmsOnSopNode grouptypeparm.set(grouptypevalue) AttributeError: 'NoneType' object has no attribute 'set' Quote Link to comment Share on other sites More sharing options...
cruiserandmax Posted May 27, 2015 Author Share Posted May 27, 2015 If anyone could provide an example of the correct way to use a selector on an otl to automatically populate the group field I would really appreciate it! Quote Link to comment Share on other sites More sharing options...
edward Posted May 29, 2015 Share Posted May 29, 2015 Look at the help: http://www.sidefx.com/docs/houdini14.0/hom/hou/SopNodeType#addSelector Notice the description for "group_type_parm_name" which says, ...If None, the selector will look for a parameter named “grouptype”. I'm guessing that your node has no parameter named "grouptype". Quote Link to comment Share on other sites More sharing options...
cruiserandmax Posted May 30, 2015 Author Share Posted May 30, 2015 Holy cow you got it- thanks, edward! It's funny I've been staring at those docs ever since I began trying to do this and it just didn't dawn on me to even try creating an attribute named grouptype since I was setting the Selector type to "points" which does not allow it to use different geometry types. But I guess that are just needs to still be there to abode reprint in creation mode. It's weird because without that attr the selector still functions to populate the group field- you just need to lay down and connect the nose first before going into selection mode. Great suggestion!! Quote Link to comment Share on other sites More sharing options...
edward Posted June 1, 2015 Share Posted June 1, 2015 You might be able to avoid it with group_type_parm_name="" (ie. the empty string). 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.