gfern93 Posted September 13, 2018 Share Posted September 13, 2018 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 Quote Link to comment Share on other sites More sharing options...
davpe Posted September 14, 2018 Share Posted September 14, 2018 hi, maybe Partition SOP will help you: https://vfxbrain.wordpress.com/2017/09/15/groups-from-attribute/ if you've got your names ready it should be fairly easy... Quote Link to comment Share on other sites More sharing options...
Alain2131 Posted September 14, 2018 Share Posted September 14, 2018 (edited) 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 September 14, 2018 by Alain2131 1 Quote Link to comment Share on other sites More sharing options...
gfern93 Posted September 14, 2018 Author Share Posted September 14, 2018 @Alain2131 thank you so much, I never knew that about groups! I had ended up using as foreach and set the piece attrib to my test attribute. But it's great to know what the issue was! I'm making an asset so I'll post it in the HDA forum in a day or two Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.