Hi,
I noticed there's a usd_parentpath() function but no usd_childpath()/usd_childrenpaths() function. I'm guessing this has to do with the wrangle being multithreading safe, but how would I go about the following problem otherwise:
All children prims hold an attribute (like polygon count) and I want to sum those up and write the sum as an attribute on the parent primitive.
vex usd_childpath()
3144 4 1-
- marcosimonrbl
- Member
- 23 posts
- Joined: 9月 2021
- オフライン
-
- rafal
- スタッフ
- 1471 posts
- Joined: 7月 2005
- オフライン
I've added an RFE for the `usd_childrennames()` VEX function.
If you know the children names, you can form the child path by appending "/" and a child name to the parent's path.
Otherwise, as a workaround for this task, you can try the Python LOP.
EDIT: RFE number is 116741
If you know the children names, you can form the child path by appending "/" and a child name to the parent's path.
Otherwise, as a workaround for this task, you can try the Python LOP.
EDIT: RFE number is 116741
Edited by rafal - 2021年10月19日 18:11:24
-
- marcosimonrbl
- Member
- 23 posts
- Joined: 9月 2021
- オフライン
-
- goldleaf
- スタッフ
- 4258 posts
- Joined: 9月 2007
- オフライン
Another alternative approach could use two wrangles. The first would run on each mesh prim, and put the count value in a unique attribute on an ancestor primitive. Then the second wrangle would iterate over those ancestor prims, and sum the values together.
First wrangle (here we're counting the meshes on the "grandparent" prim):
Second wrangle:
Might be useful until getting child prims is possible!
First wrangle (here we're counting the meshes on the "grandparent" prim):
// Get Point Count vector pts[] = usd_attrib(0, @primpath, "points"); // Get mesh prim's name, as well as parent prim's name, to // place a unique attribute on the "grand-parent" prim. string parent = usd_parentpath(0, @primpath); string grandparent = usd_parentpath(0, parent); // Add and set counter attribute on the grandparent prim string attrib = "counter_"+usd_name(0,parent)+"_"+usd_name(0, @primpath); usd_addattrib(0, grandparent, attrib, "int"); usd_setattrib(0, grandparent, attrib, len(pts));
Second wrangle:
string attribs[] = usd_attribnames(0, @primpath); string prefix = "counter_"; int total = 0; foreach(string attr; attribs) { if (startswith(attr, prefix)==1) { total += usd_attrib(0, @primpath, attr); } } i@totalMeshCount= total;
Might be useful until getting child prims is possible!
I'm o.d.d.
-
- tamte
- Member
- 9281 posts
- Joined: 7月 2007
- オフライン
-
- Quick Links