Automatically create list of groups in MetaGroups

   3704   2   0
User Avatar
Member
874 posts
Joined: 10月 2008
Offline
I have a large number of metaballs which each one of them having its own group.

Now I want to use the MetaGroups SOP and automatically populate it with all the groups, one entry per group. Is that possible?
--
Jobless
User Avatar
Member
257 posts
Joined: 11月 2007
Offline
yes, you can do that.
if you look at what the metagroups actually does:
It creates a detail attribute called:
metaExpression
with a value like:
max(sum(“grp_01”),sum(“grp_02”))

(you can do exactly the same by adding a string details attribute with that max(sum….) string in it as it's string value).

So this has now become an exercise in string concatenation.
with the primgroupmask() expression you get your grouplist:
“grp_01 grp_02”
with the arg(list,argnum) you tokenize the list.
with argc(list) you count the total number of elements (so you can use this as the final number in the foreach - making sure the foreach starts at 0)

with an attribcreate you generate the start of the string and update it inside the foreach.
attribcreate -> final_expr (string)
stringvalue: max(

inside the foreach:
attribcreate -> final_expr (string)
stringvalue:
`$FINAL_EXPR`sum(“`arg(primgroupmask(”../../START“,”grp_*“),stamp(”..“, chs(”../forstamp“), 0) )`”)

with a switch statement that specifies to add a comma or not:
switch expression:
stamp(“..”, chs(“../forstamp”), 0) != ch(“../numrange2”)

attribcreate -> final_expr (string)
stringvalue:
`$FINAL_EXPR`,

This really is more of a python expression kind of thing as it deals with strings better. But you can do it with a foreach as well.
Cg Supervisor | Effects Supervisor | Expert Technical Artist at Infinity Ward
https://www.linkedin.com/in/peter-claes-10a4854/ [www.linkedin.com]
User Avatar
Member
4 posts
Joined: 11月 2012
Offline
I tried to recreate this but I only get one group into it
  • Quick Links