Hello.
I'm trying to find an automated solution to separate geometry into multiple SOPs depending on group membership.
In the uploaded example. The file SOP contains a geometry that has predefined four groups: smallBox, medBox, largeBox and sphere.
I have separated them manually, by linking multiple Delete SOPs (Delete Non-Selected) to the file SOP - one for each group, but while it's okay when there are only a few groups, it gets tedious when there are more.
What would be the best approach to this problem?
Maybe forEach node? But if so, then how do I determine names of groups to iterate on, if they don't follow some sort of pattern? And how do I fork the pipes later on?
P.S. I realise I can do this with a Python script, but I'd rather like to use nodes if possible.
Automatic geometry separation, depending on group membership
3821 3 0- ajz3d
- Member
- 477 posts
- Joined: 8月 2014
- Online
- pezetko
- Member
- 387 posts
- Joined: 11月 2008
- Offline
Put * in the Group Mask parameter of for each sop to process all groups.
If you want just save them, put File SOP inside forEach and set the name based on current loop (FORIDXVALUE or FORVALUE stamp expression).
If you want to create forking in the network view, I would use python script to iterate over each group and putting blast/delete sop by it.
E.g.:
import hou
#select file sop
selectedNode = hou.selectedNodes()
groups = selectedNode.geometry().primGroups()
for group in groups:
blastNode = selectedNode.createOutputNode('blast')
blastNode.setName(“keep”+group.name())
blastNode.parm('group').set(group.name())
blastNode.parm('negate').set(1)
If you want just save them, put File SOP inside forEach and set the name based on current loop (FORIDXVALUE or FORVALUE stamp expression).
If you want to create forking in the network view, I would use python script to iterate over each group and putting blast/delete sop by it.
E.g.:
import hou
#select file sop
selectedNode = hou.selectedNodes()
groups = selectedNode.geometry().primGroups()
for group in groups:
blastNode = selectedNode.createOutputNode('blast')
blastNode.setName(“keep”+group.name())
blastNode.parm('group').set(group.name())
blastNode.parm('negate').set(1)
- ajz3d
- Member
- 477 posts
- Joined: 8月 2014
- Online
pezetkoThanks for your reply, Pezetko.
Put * in the Group Mask parameter of for each sop to process all groups.
If you want just save them, put File SOP inside forEach and set the name based on current loop (FORIDXVALUE or FORVALUE stamp expression).
I'm running into some problems with this one.
I use “$HIP/output/$FORVALUE.obj” string as a “Geometry File” parameter inside file SOP. I expected from $FORVALUE to assume values of each PrimGroup.name() of the input, similar to loops:
for primGroup in geo.primGroups(): # (…)
with $FORVALUE stamp being the equivalent of the primGroup variable in the example above. Turns out I'm wrong, because when I place the file node just before the ‘each’ node inside the forEach SOP, all I get is just one output file called ‘.obj’ - it doesn't even have a name, just an extension. It contains all groups from the input. What am I doing wrong here?
Yes, this is how I do it ATM.
import hou
#select file sop
selectedNode = hou.selectedNodes()
groups = selectedNode.geometry().primGroups()
for group in groups:
blastNode = selectedNode.createOutputNode('blast')
blastNode.setName(“keep”+group.name())
blastNode.parm('group').set(group.name())
blastNode.parm('negate').set(1)
I understand that it is not possible to fork the flow into n-streams without scripting?
- pezetko
- Member
- 387 posts
- Joined: 11月 2008
- Offline
-
- Quick Links