Jump to content

Copy group in vex?


MJGaiser

Recommended Posts

So I have a prim wrangle with an input that has all its primitives in a group called "allPrims". I am doing a loop where each time, I need to reset the group and make sure it contains all the primitives as I am removing certain ones within the loop. I thought that I could just make a copy of the initial group ("current") and remove the primitives from that copy then for each prim in the wrangle it would just refresh the the group based on the initial "allPrims" group. The only problem is that I cannot seem to copy the group. I am trying to do so like this: 

 

s@group_current = s@group_allPrims;

 

This will create a group called current, but it will not have the primitives from the "allPrims" in it. How do you copy the contents of one group to another in vex? And as an alternative method which might just be easier, How do you assign all primitives from input 0 to a group as this could be done to refresh the group for each loop? Thanks!

Link to comment
Share on other sites

Im not sure. Doesn't that only assign the current prim to @group_newgroup? That would after all the prims have been looped through, result in all of them being in the group, but I am looking for a way to assign all the prims to that group during the evaluation of the first prim. Basically each prim would see that group get recreated ("Refreshed") with all the prims from input 0.

Link to comment
Share on other sites

You can set membership in for loop by setprimgroup() and same functions, but you still cannot create group within same wrangle for expanding or membership testing later. When you try to use newly created group, you will get nothing, because such functions always look on input geometry.

// Primitive wrangle.
for (int i = 0; i < @numprim; i++)
{
    setprimgroup(0, "newgroup", @primnum, true);
}

i@ingroup1 = inprimgroup(0, "newgroup", @primnum);
i@ingroup2 = @group_newgroup;
i[]@prims_in_group = expandprimgroup(0, "newgroup");

It will create group correctly (you may add condition to run for loop only on first primitive for speed, it does not matter here), but membership tests will fail and the group will expand into an empty array. Look at arrays for storing some data to access it later in wrangle. Or simply make several wrangles.

 

input_limitation.hipnc

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...