Jump to content

expression question


Lukich

Recommended Posts

Hello again :) I was wondering if there's an expression in houdini that allows me to get a number of points in the group. Pointlist() returns a string with a list of those points, which is almost what I need. Is there a way to convert the pointlist output into an integer equal to the number of points?

thanks a lot,

Luka

Link to comment
Share on other sites

Hello again :)  I was wondering if there's an expression in houdini that allows me to get a number of points in the group.  Pointlist() returns a string with a list of those points, which is almost what I need.  Is there a way to convert the pointlist output into an integer equal to the number of points?

thanks a lot,

Luka

14803[/snapback]

Try this:

float NPointsInGroup(string sop; string group_name) {
  float i = 0;
  string pt_list = pointlist(sop, group_name);
  float list_len = strlen(pt_list);
  float pt_num = 0;
  for(i = 0; i < list_len; i++) {
    if(substr(pt_list, i, 1) == "\x20") pt_num++;
  }
  return pt_num - 2;
}

Link to comment
Share on other sites

Try this:

float NPointsInGroup(string sop; string group_name) {
  float i = 0;
  string pt_list = pointlist(sop, group_name);
  float list_len = strlen(pt_list);
  float pt_num = 0;
  for(i = 0; i < list_len; i++) {
    if(substr(pt_list, i, 1) == "\x20") pt_num++;
  }
  return pt_num - 2;
}

14807[/snapback]

Interesting. Houdini's Custom expr function accepts hex value? I didn't know that. :o

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...