Jump to content

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 

Link to comment
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.

Link to comment
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
Link to comment
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  

Link to comment
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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...