Hi,
with python or any commands in textport or whatwever,
how would I select a group with selecting a point or prim in the group?
selecting group by selecting prim/point
3465 1 1-
- fkkcloud
- Member
- 26 posts
- Joined: Aug. 2007
- Offline
-
- koen
- Member
- 795 posts
- Joined: April 2020
- Offline
I use this as a shelve tool. There should be some code in there to get you started.
Cheers,
Koen
import toolutils
import soptoolutils
import doptoolutils
import poptoolutils
import os
# find out curr context
active_pane = toolutils.activePane(kwargs)
if active_pane is not None and \
active_pane.type() == hou.paneTabType.ContextViewer:
active_pane = active_pane.sceneViewer()
if active_pane is None or active_pane.type() != hou.paneTabType.SceneViewer:
raise hou.Error(“The tool was not invoked in the scene viewer.”)
scene_viewer = active_pane
child_type = scene_viewer.pwd().childTypeCategory()
if child_type == hou.sopNodeTypeCategory():
prompt = toolutils.selectionPrompt(hou.sopNodeTypeCategory())
selection = scene_viewer.selectGeometry(prompt)
# get the displayed node to work on the geometry
node = scene_viewer.pwd().displayNode()
geo = node.geometry()
groups = geo.primGroups()
group_names =
# get the primitives from the selection pattern
prims=geo.globPrims(str(selection))
for group in groups:
for prim in prims:
if group.contains(prim):
group_names.append(group.name())
break
choices = hou.ui.selectFromList(group_names, message='Groups')
names = ‘'
for i,n in enumerate(group_names):
if i in choices:
names = names + ’ ' + n
print names
Cheers,
Koen
import toolutils
import soptoolutils
import doptoolutils
import poptoolutils
import os
# find out curr context
active_pane = toolutils.activePane(kwargs)
if active_pane is not None and \
active_pane.type() == hou.paneTabType.ContextViewer:
active_pane = active_pane.sceneViewer()
if active_pane is None or active_pane.type() != hou.paneTabType.SceneViewer:
raise hou.Error(“The tool was not invoked in the scene viewer.”)
scene_viewer = active_pane
child_type = scene_viewer.pwd().childTypeCategory()
if child_type == hou.sopNodeTypeCategory():
prompt = toolutils.selectionPrompt(hou.sopNodeTypeCategory())
selection = scene_viewer.selectGeometry(prompt)
# get the displayed node to work on the geometry
node = scene_viewer.pwd().displayNode()
geo = node.geometry()
groups = geo.primGroups()
group_names =
# get the primitives from the selection pattern
prims=geo.globPrims(str(selection))
for group in groups:
for prim in prims:
if group.contains(prim):
group_names.append(group.name())
break
choices = hou.ui.selectFromList(group_names, message='Groups')
names = ‘'
for i,n in enumerate(group_names):
if i in choices:
names = names + ’ ' + n
print names
-
- Quick Links

