Jump to content
haggi

centroid in pointWrangle

Recommended Posts

Hi,

 

I try to get the centoid of an object in a pointWrangle node. First I added a float3 attribute to the pointWrange and set the values of this attribute to the centroid of my object like: centroid("../myCube", D_X) etc. This works fine, the values are updated. Now I try to use this attribute in my pointWangle code  with: `chs("centerAttribx")`. But it seems that this procedure does not update the values in the pointWrange node.

 

My solution is to create a point with an add node set the position of the point to the centroid and plug this node into the second input of my pointWrange node. This works so far, but I'd like to know if there is a more elegant way to get the centroid directly from within a pointWrangleNode.

 

Share this post


Link to post
Share on other sites

well, chs returns string - in your case chv should work.

Share this post


Link to post
Share on other sites

Hi Haggi,

 

I was wondering if you could share that file with us. I was under the impression that you can't run Houdini expression language in wrangle nodes, and that you were limited only to VEX. I would love to learn how you got that to work. I have tried using expressions like centroid() in the past, but remember getting errors due to that.

Thanks,

Ilan

Share this post


Link to post
Share on other sites

centroid() doesn't work in vex.

Create a 3float (or vector) spare parameter on wrangle. use centroid() expression there and then reference that parameter in wrangle using ch() function.

Share this post


Link to post
Share on other sites

This should work too (VEX only):

vector min, max;
getbbox(min, max);
vector center = (min+max)/2;
Edited by rayman
  • Like 4

Share this post


Link to post
Share on other sites

What would be the best way to get those initial 'min' and 'max' vectors from the geometry?

Thanks.

Share this post


Link to post
Share on other sites

 

The min and max vectors are returned by the getbbox() function. 

In H16... you can get the same result with getbbox_center().

 

  • Like 2

Share this post


Link to post
Share on other sites

I though I would have to come with the vector min,max myself which really doesn't makes much sense.

 

Thanks!

Share this post


Link to post
Share on other sites

promoting P to a detail attribute (by avg, min/max etc.) can be a useful trick too!

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

×