Groupcopy by name attribute

   2756   6   1
User Avatar
Member
79 posts
Joined: Feb. 2008
Offline
Hello,

We constantly have to transfer attributes and groups from one asset that comes from one Alembic to another asset that comes from another that have different hierarchies. We extract a @name from the @path attribute to match the pieces by name and then we can use foreach loops or attribcopy with a Match by Attribute by “name” activated to copy attributes from one mesh to another.

The groupcopy doesn't have a Match by Attribute by “name” option though.

Inside a compiled block, I created a foreach loop by name that uses a blast for the second input (fetch input) to isolate each piece by name and do a groupcopy piece by piece.

It works, I'm just wondering if that's the most efficient way to do this? Anybody has any better recommendation on how to handle this sort of scenario?

Thanks.
User Avatar
Member
7740 posts
Joined: Sept. 2011
Offline
No foreach necessary, that reorders the geometry in undesirable ways anyways. Use findattribvalue and inprimgroup/inpointgroup to do the correlation for you in vex/vops.

In a wrangle it would be something like this:

int pr = findattribvalue(1, "prim", "name", @name, 0);
@group_mygroup = inprimgroup(1, "mygroup", pr);

This will only work if the name attribute and group membership overlap completely. If there are primitives with the same name but different group membership, this will fail.
User Avatar
Member
8531 posts
Joined: July 2007
Online
also nametoprim() and nametopoint() may come in handy in this situation as a shortcut for findattribvalue() by name attrib
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
79 posts
Joined: Feb. 2008
Offline
I won't necessarily know how many groups there will be. I'm guessing there's a way to get all groups and loop through them to recreate them on the current geometry?

I'm not sure I follow you on the nametoprim() function. How is that suppose to help?
User Avatar
Member
79 posts
Joined: Feb. 2008
Offline
I figured it out:

int pr = findattribval(1, "prim", "name", @name, 0);
string groups[] = detailintrinsic(1, "primitivegroups");
foreach (string group; groups){
    setprimgroup(0, group, @primnum, inprimgroup(1, group, pr), "set");
}

For primitive groups, which is the only group type I care about anyways.

I'm still not sure I understand the nametoprim() function and it's usefulness though.
User Avatar
Member
8531 posts
Joined: July 2007
Online
MathieuLeclaire
I'm not sure I follow you on the nametoprim() function. How is that suppose to help?
just to simplify what jsmack wrote, it may be easier to remember and use than findattribval()

int pr = nametoprim(1, s@name);
@group_mygroup = inprimgroup(1, "mygroup", pr);

if you want to do all prim groups for example, just get their names from detail intrinsic:
int pr = nametoprim(1, s@name);
string primgrps[] = detailintrinsic(1, "primitivegroups");
foreach(string grp; primgrps){
    int isin = inprimgroup(1, grp, pr);
    setprimgroup(0, grp, @primnum, isin);
}

EDIT: glad you figured it out
Edited by tamte - March 19, 2018 16:18:06
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
79 posts
Joined: Feb. 2008
Offline
Oh I understand now. Thanks.
  • Quick Links