Grouping and Foreach

   7377   10   2
User Avatar
Member
217 posts
Joined: March 2006
Offline
Hi again,
I have an object with a number of lines inside one SOP and need to build groups. I try to explain:

1. I have:

f.e. A sop with 4 lines

2. I want an output (maybe foreach):

- group1 with Line 1 and 2
- group2 with Line 2 and 3
- group3 with Line 3 and 4

Thanks for help

Detlef
User Avatar
Member
217 posts
Joined: March 2006
Offline
Sorry, I forgot:
this must be full procedural because I have different amounts of lines.
User Avatar
Member
69 posts
Joined: July 2007
Offline
I would use a copy/delete combination
null1
a place holder used later
delete1:
Group`stamp(“../copy1”,“line”,0)`
Operation Delete Non-Selected
branch from null1
sort1
Primitive tab
Primitive Sort: Shift
Offset: -1
delete2
Group`stamp(“../copy1”,“line”,0)`
Operation Delete Non-Selected
merge1:
merge both delete1 and delete2
group1
Create tab
Group Name:linegroup`padzero(4, stamp(“../copy1”,“line”,0))`
Number tab
Operation: Group By Pattern
Pattern:0-1
copy1
Copy tab:
Number of copies: nprims(“../null1”)-1
Stamp tab:
check Stamp Inputs
tab 1-10:
Variable 1:line
Value 1:$CY

This should give you a number of group equal to one less than the number of lines feed in.

Using the padzero function gives you a fixed trim value if you want for finding the groupvalue later on.
If you do not want to use the padzero you can replace this line
linegroup`padzero(4, stamp(“../copy1”,“line”,0))`
with
linegroup`stamp(“../copy1”,“line”,0)`
Hope this helps
User Avatar
Member
217 posts
Joined: March 2006
Offline
wonderful! that works!!!!!

Thanks a lot. And what a description…

Have a nice day?
Detlef
User Avatar
Member
2199 posts
Joined: July 2005
Online
Couldn't you just use the partition sop with an expression like this in it

Group`floor($PR/2)`
The trick is finding just the right hammer for every screw
User Avatar
Member
217 posts
Joined: March 2006
Offline
ha, it gives you only pairs with different PR numbers (12, 34) oad not (12, 23, 34)
Maybe there is another expression but I'm too stupid for such math

Thanks
Detlef
User Avatar
Member
2199 posts
Joined: July 2005
Online
Sorry I misunderstood. It gives you what you listed in your first mail.
The trick is finding just the right hammer for every screw
User Avatar
Member
8594 posts
Joined: July 2007
Offline
here is an example with foreach if you are interested

Attachments:
group_forEach.hip (47.1 KB)

Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
2199 posts
Joined: July 2005
Online
Simon
Sorry I misunderstood. It gives you what you listed in your first mail.

Oh, no it doesn't I misread what you had written. You need each entry to appear in two groups. Sorry

How about this?
Edited by - Dec. 12, 2008 08:56:11

Attachments:
group.hip (37.9 KB)

The trick is finding just the right hammer for every screw
User Avatar
Member
401 posts
Joined:
Offline
You can actually use two partitionSOPs and a sortSOP to select the pairs you need.
The delete sop deletes all but one group per frame to show the results.

Attachments:
setup_select_12_23_34_45.hip (41.8 KB)

this is not a science fair.
User Avatar
Member
217 posts
Joined: March 2006
Offline
here is my solution with a big help from all of you, special from Mario Marengo

http://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&p=66345#66345 [sidefx.com]

Now I have still trouble with some point normals.

See attached Hip file for building a Line with bows as an first step and

Attachments:
PipeTrouble.jpg (14.5 KB)
Pipes01.hip (144.1 KB)

  • Quick Links