Get viewport selection with python callback.

   4730   3   0
User Avatar
Member
126 posts
Joined: Aug. 2010
Offline
I've searching the web I can't seem to find a good solution this.

I want to use a callback script to get the string of the selection pattern from the viewport selection.

The code underneath, when called as a gives me infinite recursion errors, ending with Houdini crashing.

import toolutils
def getSelection():
	viewer = toolutils.sceneViewer()
	geo = viewer.selectGeometry()
	print geo.mergedSelectionString()  

Any ideas?
Edited by aeaeaeae - July 8, 2016 10:12:05
User Avatar
Member
2538 posts
Joined: June 2008
Offline
You may want to poke around on the scripting forum on OdForce. I have seen related topics come up a few times.
http://forums.odforce.net/topic/25237-python-returning-currently-selected-face-and-then-growing-the-selectio/#comment-147403 [forums.odforce.net]
Edited by Enivob - July 9, 2016 09:45:31
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
260 posts
Joined: Nov. 2014
Offline
would this help?
Im using it as action button, that allows me to select geo in veiwport and output selected geo name

import soputils 
kwargs['geometrytype'] = (hou.geometryType.Primitives,) 
kwargs['inputindex'] = 0 
soputils.selectGroupParm(kwargs)
User Avatar
Member
126 posts
Joined: Aug. 2010
Offline
@martinkindl83 thanks that worked like a charm.

Full solution:

1. Go to Edit Parameter Interface,
2. Add a string parameter to you node.
3. Under the “Action Button” tab of you string parameter, past the code of martinkindl83.

import soputils 
kwargs['geometrytype'] = (hou.geometryType.Primitives,) 
kwargs['inputindex'] = 0 
soputils.selectGroupParm(kwargs)

4. There should now be a gear icon to the right of the new string field of your node.
Edited by aeaeaeae - July 12, 2016 05:31:29
  • Quick Links