Select geometry components from script

   4491   9   0
User Avatar
Member
538 posts
Joined: 12月 2006
オフライン
So, maybe in H14 we can now select geometry components from python?
With SceneViewer.selectGeometry we give the chance user to select comps interactively.
What about automatically select comps from script? Something like:
selectPrims(“3-10”)
https://gumroad.com/alexeyvanzhula [gumroad.com]
User Avatar
Member
538 posts
Joined: 12月 2006
オフライン
I find H14 solution !!!

def select_geometry( mask='0', geometry_type=hou.geometryType.Primitives ):
viewer = toolutils.sceneViewer()
if viewer is not None:
viewer.selectGeometry(use_existing_selection=False, initial_selection_type=geometry_type, initial_selection=mask)
https://gumroad.com/alexeyvanzhula [gumroad.com]
User Avatar
Member
8077 posts
Joined: 7月 2005
オフライン
That looks like an solution that would have worked since H9 to me.
User Avatar
Member
538 posts
Joined: 12月 2006
オフライン
No !!!
H14 has NEW initial geometry arguments in hou.SceneViewer.selectGeometry method

:twisted: :twisted: :twisted:
https://gumroad.com/alexeyvanzhula [gumroad.com]
User Avatar
スタッフ
4565 posts
Joined: 7月 2005
オフライン
Yes, the initial geometry argument is new. Sorry, I didn't see this thread earlier or I would have mentioned this. That new argument was added primarily to support the new “group reselection” buttons that showed up next to most Group parameters in SOPs. That button just runs a python script which starts up a selector using the existing Group parameter value as the initial selection. That code can be found in $HFS/houdini/scripts/python2.X]libs/soputils.py, selectGroupParm().
User Avatar
Member
538 posts
Joined: 12月 2006
オフライン
Yes it is good addition. But I still need press ENTER to accept selection
I didn't notice this behaviour yesterday.

So it is not so good for automatization tricks in my scripts
https://gumroad.com/alexeyvanzhula [gumroad.com]
User Avatar
スタッフ
4565 posts
Joined: 7月 2005
オフライン
I'm sure I'm missing something, but if you know the string form of the selection you want, and you don't want the user to actually be able to modify the selection before accepting it, why not just put the group string directly into the Group parameter of the SOP you are interested in? That's all that the selector does when you hit enter… I'm not sure why you want to involve a selector at all?

Mark
User Avatar
Member
538 posts
Joined: 12月 2006
オフライン
Good question. This is old problem

I use this trick in my interactive tools.

For example, after my tool finish i want to highlight components to use it in next tool if need.

It is very good if main node of my tool is created by soptoolutils.genericTool. In this case components automatically selected (highlighted)

But, if node created manually (with hou.Node.createNode()) it can`t highlight components, except ‘group’ node

So, my temporary solution is creating ‘group’ node after main node and highlight components with hou.SceneViewer.enterCurrentNodeState() Works well, but IMO this is not good
https://gumroad.com/alexeyvanzhula [gumroad.com]
User Avatar
Member
8077 posts
Joined: 7月 2005
オフライン
vux
But, if node created manually (with hou.Node.createNode()) it can`t highlight components, except ‘group’ node

Isn't this just because the “highlight” flag is not set on the node in that case? Try calling node.setHighlightFlag(True)
User Avatar
Member
538 posts
Joined: 12月 2006
オフライン
o shit, i`m stupid idiot.
Thanx edward you saved me

It is very interesting that i asked questions (without answers) like this not once , and I never noticed highlight flag
https://gumroad.com/alexeyvanzhula [gumroad.com]
  • Quick Links