Jump to content

Looping over Groups with only Points


Wout

Recommended Posts

Hi,

here's what I've done with vex so far working on a point cloud : Created groups based on clusters/distance

What I'd like to now is to be able to do stuff to those individual groups. With a for each /loop or something. Buuuut as there are only points, the promote group sop( set to point  -> primitives )  creates prim groups but empty ones. So I can't use that in a for loop

Any ideas ?

Thank You. 

 

Wout

Link to comment
Share on other sites

Hi ThomasPara, thanks. Maybe a little confusing but when I said cluster, I  didn't know about the actual cluster SOP. So I have  a point cloud with Point Groups assigned with Vex in an Point Wrangle. And I'd like to "split" or separate the groups , do stuff to those individual streams and merge them back together.

 

Thank you :)

Link to comment
Share on other sites

I hope I understand this correctly. There's 2 things you could do:

1) Don't use groups, attributes are superior in most cases. Instead of creating groups, create an integer or string attribute and use that as Piece Attribute on the loop, like ThomasPara suggested.

2) The name SOP can build names from groups, from there it's the same as 1)

Iirc the old foreach subnet had the option to run over groups, the new ones does not.

Link to comment
Share on other sites

OKay I just tried this and it worked:

 

Point wrangle 

Run over " detail ( only once)

//////////////////////////////////////////////////////////////////////////////////////////////////

int ptCount = detailintrinsic(0, "pointcount"); 

int counter = 0;

 

for(int i=0; i<ptCount; i++)
{

if(ENTER CONDITION FOR GROUPING HERE) counter+=1;

groupName = sprintf("group_%d", counter); 

"setpointattrib(0, "groupName", i, groupName);

}

//////////////////////////////////////////////////////////////////////////////////////////////////

in my vex and then used "groupName" as piece attribute.

 

Man I've been looking all night for that, literally :)

Edited by Wout
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...