Jump to content

Creating multiple groups by point attribute


gfern93

Recommended Posts

Hello Odforce, 

 

I'm trying to create groups based on the @P.y attribute of a bunch of vertical lines I have. I am almost there, but I'm not exactly a Vexpert and can't figure out exactly how to assign multiple groups with different names.

I'm able to create a string attribute with the correct name for the groups with 

s@test = sprintf("%f", @P.y);
s@groupname = concat("group_", @test);

 

I tried using setpointgroup(0, @groupname, @ptnum, 1, "set") after this, but it didn't do anything, now I'm just stumped on how to approach assigning this attribute as a group.

Any input would be greatly appreciated! Thank you

 

 

Link to comment
Share on other sites

Hey Amaya,

I'm guessing that your code probably works, it's just that you can't have a point ( . ), nor a comma ( , ) in a group name.
So in your setup every points of your lines must have had some non-int value, resulting in no groups created at all.

Try multiplying the position by 100 and add it as an integer to your group name, or anything that eliminates the point.

This is my attempt. Keep in mind that you need to set your wrangle to Run Over Detail.

int ptCount = detailintrinsic(0, "pointcount"); // Get the point count

// Initial attributes setup
vector thePos = {0,0,0};
string groupName = "";

for(int i=0; i<ptCount; i++)
{
    thePos = point(0, "P", i); // Get the position
    
    groupName = sprintf("group_%d", thePos[1]*100); // Create the groupName variable
    // For some reasons, the groups doesn't accept commas, nor points ( , . )
    
    //printf("%d ", groupName);
    
    setpointgroup(0, groupName, i, 1);
}

Here's a quick scene with that code.

set_group_by_Y.hip

EDIT :

.. Actually, here's the same scene but with your code, working.

s@test = sprintf("%d", @P.y*100); // %d to have an integer
s@groupname = concat("group_", @test);

setpointgroup(0, @groupname, @ptnum, 1);

set_group_by_Y_1.hip

Edited by Alain2131
  • Thanks 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...