Jump to content

String formatting group names in VOP SOP


Recommended Posts

Hi,

I'm trying to create multiple groups in a VOP SOP network, each group name containing the current point number, mygroup_<ptnum>. I format the name of each group with a Print node, which formats the string correctly, but apparently only passes mygroup_0 to the Create Point Group node, no matter what ptnum is. I'm attaching a file that hopefully makes this clearer. Am I using the Print node incorrectly? Is there a better way to do this?

Thanks!

createMultipleGroupsInVOPSOP.hipnc

Link to comment
Share on other sites

Ofcourse if you want to create groups from point numbers of points that contains some attributes and you don't want names with points that don't contain attrib you have to add a little more code. Example below.

Link to comment
Share on other sites

As I sad in previous post, example below... forgot to atach file ;).

EDIT: little mistake in code, dont initilize i to $ptnum, instead initialize it to 0.

BTW. If you heavn't knew this, in H11 you can create groups with Python directly now, you don't need some funky self made solutions.

createMultipleGroupsInVOPSOP_FIX2.hipnc

Edited by SWANN
Link to comment
Share on other sites

Thanks for the solution and extra tips, that's very helpful!

I'm curious, in the inline solution, there is a for-loop creating multiple groups each time the VOP SOP is run. If I understand right, the VOP network runs for each point passed into it, so it seems multiple groups are being created by the loop for each point passed through the network. It seems the following code should create a group for the current point (without needing the for-loop), then since the VOP network iterates through each point (creating a group each time), the extra for-loop is not needed:

string groupName = sprintf("neighbor_grp_INLINE_%d", i);

newgroup(groupName);

But that turns out to be incorrect. Why is that?

Link to comment
Share on other sites

string groupNormalName = sprintf("neighbor_grp_NORMAL_%d", $ptnum);
addgroup(groupNormalName, $ptnum);

$out = groupNormalName;

if you print this code you will see that it creates 100 names with different point number. But it doesn't create 100 strings how you think. VOPs are SIMD (single instruction, multiple data) so that means they apply one instruction to all data, so in this example it adds ONE string (not 100 strings) to all points and when you print it it reads point number from point you are reading this string from, $ptnum is like local expression, but it's still one string "neighbor_grp_NORMAL_$ptnum". The same is with addgroup. MMB and you will see that it created one group and applied it to all points, it doesn't created 100 groups, only one operation and use it for multiple data. But it's group so you will not get multiple names of a group if you read it from another point, on each point group is the same.

Edited by SWANN
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...