Get viewport selection with python callback.
4730
3
0
aeaeaeae
Member
126 posts
Joined: Aug. 2010
Offline
July 8, 2016 10:10 a.m.
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
Enivob
Member
2538 posts
Joined: June 2008
Offline
July 9, 2016 9:44 a.m.
Edited by Enivob - July 9, 2016 09:45:31
Using Houdini Indie 20.0 Windows 11 64GB Ryzen 16 core. nVidia 3050RTX 8BG RAM.
July 10, 2016 7:56 p.m.
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 )
aeaeaeae
Member
126 posts
Joined: Aug. 2010
Offline
July 12, 2016 5:31 a.m.
@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