按照组拆分模型
nodeList = list(hou.selectedNodes())
# 遍历选中的每个节点
for node in nodeList:
# 创建一个包含不同类型(点、面、边)分组的字典
group = {
'point': node.geometry().pointGroups(),
'prim': node.geometry().primGroups(),
'edge': node.geometry().edgeGroups()
}
# 遍历每个分组类型
for child, allgroup in group.items():
# 获取当前分组类型下的所有分组
for a in allgroup:
# 获取分组名称
name = a.name()
# 创建一个 blast 节点
blast = node.createOutputNode('blast')
# 设置 blast 节点的组参数为当前分组名称
blast.parm('group').set(name)
# 将 blast 节点设置为负选择(删除分组内的几何)
blast.parm('negate').set(1)
# 设置 blast 节点以删除指定分组
blast.parm('removegrp').set(1)
# 创建一个 null 节点作为 blast 节点的输出
null = blast.createOutputNode('null', "OUT_" + name)
# 设置 null 节点的颜色为绿色
null.setColor(hou.Color(0, 1, 0))