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.
Groupcopy by name attribute
2702 6 1- MathieuLeclaire
- Member
- 79 posts
- Joined: Feb. 2008
- Offline
- jsmack
- Member
- 7659 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:
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.
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.
- tamte
- Member
- 8449 posts
- Joined: July 2007
- Online
- MathieuLeclaire
- Member
- 79 posts
- Joined: Feb. 2008
- Offline
- MathieuLeclaire
- Member
- 79 posts
- Joined: Feb. 2008
- Offline
I figured it out:
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.
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.
- tamte
- Member
- 8449 posts
- Joined: July 2007
- Online
MathieuLeclairejust to simplify what jsmack wrote, it may be easier to remember and use than findattribval()
I'm not sure I follow you on the nametoprim() function. How is that suppose to help?
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
FX Supervisor
Method Studios, NY
- MathieuLeclaire
- Member
- 79 posts
- Joined: Feb. 2008
- Offline
-
- Quick Links