Jump to content
Sign in to follow this  
charly

compare attributes in VEX

Recommended Posts

Hi,

I'm a newbie in Houdini and vex, with basic knoledge of programming.

I want to create vertex between points from 2 different objects, using vex.

The look will be the Plexus style with the difference that I don't want the points to connect from each other when they are from the same geometry.

I followed a tutorial from Entagma to help me.

 

The question is : How do I get and compare an attribute from 2 points ?

I tried to use pointattrib() to compare an attribute "myobj" that I created before but I don't have enought kwnolege yet to use it well.

 

//__ List of the closest points
int pnt_near[] = nearpoints(0, @P,dist, maxpoints);

foreach(int pnt; pnt_near){
    //__ condition if pnt and @ptnum do not share the same value of the attribute myobj
    if(pointattrib(0, myobj, pnt, 0) != pointattrib(0, myobj, @ptnum, 0) {
        int myprim = addprim(0,"polyline");
        addvertex(0, myprim, pnt);
        addvertex(0, myprim, @ptnum);
    }
}

I don't know if it's the best way, so I'll be happy to hear any solution from you.

Thanks,

Charles

 

plexus_attribute.hip

Share this post


Link to post
Share on other sites

Hi Charles,

one straightforward way would be to hook up one geo to the first input slot of your attribwrangle/pointwrangle, the other geo to the second one. Then perform a closest point search on the geo coming in through the second input only. After that you'd have to "copy" the found points into the first geo and use them to create the polylines:

float searchradius = 0.15;
int maxpoints = 5;
int points[];

points = pcfind(1, "P", @P, 2*searchradius, maxpoints);

foreach(int ptj; points)
{
    int prim = addprim(geoself(), "polyline");
    vector newpos = point(1, "P", ptj);
    int newpt = addpoint(geoself(), newpos);
    addvertex(geoself(), prim, @ptnum);
    addvertex(geoself(), prim, newpt);
}

Hope that helps, :)

Cheers,

Moritz

  • Like 2

Share this post


Link to post
Share on other sites

Thanks heaps Moritz !!!

I tried something similar, but couldn't find the proper syntax.

 

Thanks again :)

Charles

  • Like 1

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
Sign in to follow this  

×