Selected prims in Python...

   9068   7   2
User Avatar
Member
98 posts
Joined: Sept. 2008
Offline
Dear All,

I'm just wondering whether there is a way to know which primitives have been (manually) selected by the user, but through the Python API. I know you can have that information for the selected nodes through the hou.selectedNodes() or do some node selection with Node.setSelected(), but I've found no equivalent to know/set the selected primitives… is there a way to do it?

Thanks!!!

dagush.-
————————-
* skylineEngine project coordinator
* buildingEngine module developer
http//ggg.udg.edu/skylineEngine
User Avatar
Member
1908 posts
Joined: Nov. 2006
Online
In order to do anything regarding selected stuff in the viewport you'll need an instance of hou.SceneViewer. To select prims, or get any currently selected ones you would then call selectGeometry() and get the selection string from the resultant hou.GeometrySelection object.

There is no way to use Python to select any geometry entity in the viewport however.
import toolutils
viewer = toolutils.sceneViewer()
geo = viewer.selectGeometry()
print geo.mergedSelectionString()
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
330 posts
Joined: July 2007
Offline
graham


There is no way to use Python to select any geometry entity in the viewport however.


might be interesting , if that wd be true someday .

first thing that comes in my mind ; different selection patterns ( 1 of nth , next loop , previous loop , etc .. )
… oc , ideally assignable to shortcuts for viewport modelling sessions .


.cheers
except the things that cannot be seen , nothing is like it seems .
User Avatar
Member
98 posts
Joined: Sept. 2008
Offline
Thanks!!!

Now, with the risk of asking a really silly question, where can I find informatio on the toolutils library? I've seen it several times mentioned at the forums but I've never found any documentation about it…

Thanks again!!!

dagush.-
————————-
* skylineEngine project coordinator
* buildingEngine module developer
http//ggg.udg.edu/skylineEngine
User Avatar
Member
1908 posts
Joined: Nov. 2006
Online
toolutils is a Python module shipped with Houdini. It is located in $HFS/houdini/python2.Xlibs/. It, along with most of the other Python modules Houdini uses, are located in there. They contain some documentation in the form of docstrings and code comments.
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
98 posts
Joined: Sept. 2008
Offline
great!!!
I'll look at them right now!

thanks a lot for the helpful answer!

dagush.-
————————-
* skylineEngine project coordinator
* buildingEngine module developer
http//ggg.udg.edu/skylineEngine
User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
graham
import toolutils
viewer = toolutils.sceneViewer()
geo = viewer.selectGeometry()
print geo.mergedSelectionString()

thanks!

With primitives already selected in the viewport, I call this code from a button parameter: it returns the values, but also the viewport will lose the selection. Do you know how to avoid that?

It seems that it is the hou.SceneViewer.selectGeometry() function to cause this behavior.
I'm reading [www.sidefx.com] that the function should expect the user to perform the selection first and it would return the selected prims.


ps. I'm also getting this error sometimes: Execute Code - Recursion in parm callback
Edited by Andr - Feb. 3, 2019 04:45:33
User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
now I'm using that code in a radial menu script.
No more “recursion in parm callback”, but still losing the selection.
Edited by Andr - Feb. 7, 2019 19:50:14
  • Quick Links