Jump to content
Sign in to follow this  
opus2761

create groups for points on the same x axes

Recommended Posts

Hi,

 

I am still pretty new to houdini and I can't figure out this seemingly easy question... 

 

I have a box poly mesh that has divisions of 12, 6, 6. I'd like create groups for points on the same x axes. How can I achieve that? 

 

Any help is greatly appreciated. Thanks!

 

ycc 

Share this post


Link to post
Share on other sites

I was struggling for a while and then figured it out right after I posted the question.

 

assign $CR = $PT to all the points on the 1st column

attribute transfer the color value to the rest of the points

add partition sop with rule "group by color"

 

Not sure if it's the best way, but it is working.

Share this post


Link to post
Share on other sites

Point Wrangle:

float error = 0.00001;
string name = sprintf("group_y%g_z%g", rint(@P.y/error)*error, rint(@P.z/error)*error);
name = re_replace(r'\.', '_',name);
setpointgroup(0, name, @ptnum, 1);
  • Like 1

Share this post


Link to post
Share on other sites

Thank you very much Tomas! So much cleaner to use vex. I'd really like to start using it more. 

 

:) 

Share this post


Link to post
Share on other sites

 

Point Wrangle:

float error = 0.00001;
string name = sprintf("group_y%g_z%g", rint(@P.y/error)*error, rint(@P.z/error)*error);
name = re_replace(r'\.', '_',name);
setpointgroup(0, name, @ptnum, 1);

 

Hi Thomas

can You comment out these lines? What do they say? Interested in learning VEX. Thank you  

Share this post


Link to post
Share on other sites

...

can You comment out these lines? What do they say? Interested in learning VEX. Thank you  ...

sure

the idea is that all points that lie on the same axis parallel to x-axis will have the same y and z coordinate therefore group name generated using y and z position values will be the same for all points on the same x axis

 

to introduce some tolerance we can round them to certain decimal place, so rint(@P.y/error)*error rounds y coordinate and rint(@P.z/error)*error rounds z coordinate

so if y is 0.200000001 and z is 0.9000000001 then after rounding they are 0.2 and 0.9

 

then sprintf("group_y%g_z%g", y, z);  constructs string "group_y0.2_z0.9"

 

but since group names can't contain dots

 

name = re_replace(r'\.', '_',name) replaces all dots with underscores, giving you "group_y0_2_z0_9"

  • Like 1

Share this post


Link to post
Share on other sites

Thomas,
thank You verymuch! i´ve never read such a VEXcode (i am a VEX noob), very interesting. why cant group names have dots in it? just a general VEX rule to know? i guess it has a reason

Share this post


Link to post
Share on other sites

it's not about VEX, houdini geometry groups can't have dots in them, among other invalid characters

Edited by anim

Share this post


Link to post
Share on other sites

That's a very nice answer Tomas! thanks for your explanations and time.

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  

×