haggi 41 Posted December 16, 2014 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
rayman 458 Posted December 16, 2014 well, chs returns string - in your case chv should work. Share this post Link to post Share on other sites
haggi 41 Posted December 16, 2014 Thanks.... sometimes I feel so stuipd... Share this post Link to post Share on other sites
wick3dParticle 2 Posted December 16, 2014 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
pbarua 44 Posted December 18, 2014 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
wick3dParticle 2 Posted December 18, 2014 Ah, got it. I think I misread the original post. Thanks Pradeep! ~Ilan Share this post Link to post Share on other sites
rayman 458 Posted December 18, 2014 (edited) This should work too (VEX only): vector min, max; getbbox(min, max); vector center = (min+max)/2; Edited December 18, 2014 by rayman 4 Share this post Link to post Share on other sites
wick3dParticle 2 Posted December 19, 2014 Thanks Rayman. Yes, that's what I have been using. ~Ilan Share this post Link to post Share on other sites
Mzigaib 20 Posted February 23, 2017 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
Mikal 4 Posted February 25, 2017 The min and max vectors are returned by the getbbox() function. In H16... you can get the same result with getbbox_center(). 2 Share this post Link to post Share on other sites
Mzigaib 20 Posted February 26, 2017 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
Nicholas Ralabate 20 Posted February 28, 2020 fwiw, the vex snippet above seems to produce a different value than the extract centroid SOP (which can also create a centroid attribute) Share this post Link to post Share on other sites
nuki 39 Posted February 28, 2020 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