Jump to content
garf

Select one or other in group

Recommended Posts

Having a brainfart here:

I have a bunch of lines which I'm currently looping over and assigning the end points (ie. has 1 neighbour) into a group. What I now want to do is remove 1 or the other of these two points from the group.

Someone show me what a donut I'm being, please!

Share this post


Link to post
Share on other sites

Hi,
I hope that I understood it right. I have attached the file.  You could do "for each primitive" loop and wrangle something like this:

int first = 0;
int last  = -1 + primvertexcount(0, @primnum);

if (@ptnum == first)
   @Cd = {1,0,0};

if (@ptnum == last)
   @Cd = {0,0,1};

 

Or you could inside one Primitive wrangle:

 

int first = 0;
int last  = -1 + primvertexcount(0, @primnum);

int first_pt = primpoint(0, @primnum, first);
int last_pt  = primpoint(0, @primnum, last );

setpointattrib(0,"Cd",first_pt,{1,0,0});
setpointattrib(0,"Cd",last_pt,{0,0,1});

setpointgroup(0, "first", first_pt, 1) ;
setpointgroup(0, "last",  last_pt, 1) ;

 

first_last.hiplc

Share this post


Link to post
Share on other sites

I wanted to try a method which works independent of point numbers:

int npoints = npoints(0);

for (int i = 0; i<npoints; i++){
    int group = inpointgroup(0,"end_point",i);
    if (group){
        setpointgroup(0, "end_point",i, 0);
        break;
    }
}

You would put this in a detail wrangle after you create your end_point group and then replace "end_point" with whatever you named it.

This probably is not the best method for heavy geometry.

Share this post


Link to post
Share on other sites

just to select random end point per curve without any sop or vex for loops you can do (pointwrangle)

int index = -(rand(@primnum) < 0.5);
int pts[] = primpoints(0, @primnum);
i@group_randomend = pts[index] == @ptnum;

 

  • Like 2

Share this post


Link to post
Share on other sites

nice one cheers for the replies guys

as ever - @anim's snippet did the business

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×