import naming
source_node = hou.selectedNodes()[0]
output_driver = hou.node('/obj/ropnet1').createNode('geometry')
output_driver.moveToGoodPosition()
output_driver.setName(source_node.name())
output_driver.setParms({'soppath':source_node.path()})
naming.update_node_outpath(output_driver)
file_loader = source_node.parent().createNode('file')
file_loader.setInput(0, source_node, 0)
file_loader.moveToGoodPosition()
file_loader.setInput(0, None, 0)
file_loader.setName('loadback_' + source_node.name())
file_loader.parm('file').setExpression('chs("' + output_driver.path() + '/sopoutput")')
file_loader_time = source_node.parent().createNode('timeshift')
file_loader_time.setInput(0, file_loader, 0)
file_loader_time.moveToGoodPosition()
file_loader_null = source_node.parent().createNode('null')
file_loader_null.setInput(0, file_loader_time, 0)
file_loader_null.moveToGoodPosition()
#file_loader.null('OUT_' + source_node.name())
-----Blast Separate By Connectivity
update 03/Jul/2024: Add "name" attribute.
node = hou.selectedNodes()[0]
geo = node.geometry()
count = 0
merge = node.parent().createNode('merge')
value = max(geo.pointIntAttribValues('class'))
print value
for count in range(value+1):
blst_gp = "@class==" + str(count)
blast = node.parent().createNode('blast')
blast.setInput(0,node)
blast.moveToGoodPosition()
blast.parm('negate').set(True)
blast.parm('grouptype').set(3)
blast.parm('group').set(blst_gp)
pack = node.parent().createNode('pack')
pack.setInput(0,blast)
pack.moveToGoodPosition()
merge.setInput(count,blast,0)
merge.moveToGoodPosition()
merge.setDisplayFlag(True)
-----Blast Separate By Group
#node = hou.pwd()
#geo = node.geometry()
# Add code to modify contents of geo.
# Use drop down menu to select examples.
with hou.undos.group("Poly Reduce Groups"):
#uses parent, otherwise recursion happens with python sop node
node = hou.selectedNodes()[0]
geo = node.geometry()
groups = geo.primGroups()
count = 0
merge = node.parent().createNode('merge')
for o in groups:
#keep a single prim group
blast = node.parent().createNode('blast')
blast.setInput(0,node)
blast.moveToGoodPosition()
blast.parm('negate').set(True)
blast.parm('group').set(o.name())
pack = node.parent().createNode('pack')
pack.setInput(0,blast)
pack.moveToGoodPosition()
codelist = []
codelist.append('s@name = "%s";' % (o.name()))
code = '\n'.join(codelist)
wrang = node.parent().createNode('attribwrangle')
wrang.parm('snippet').set(code)
wrang.setInput(0,pack)
wrang.moveToGoodPosition()
merge.setInput(count,wrang,0)
count = count + 1
merge.moveToGoodPosition()
merge.setDisplayFlag(True)