tturner Posted April 30, 2021 Share Posted April 30, 2021 I have a point cloud with a string attribute "name" and unique values, like C, C1, N, VAX, etc how do just turn each unique name attribute into unique numerical values? so all of the "C" would be 1, C1 would be 2, etc input point cloud will change and so will the actual names. Could be hundred of unique names. Thanks T Quote Link to comment Share on other sites More sharing options...
tturner Posted April 30, 2021 Author Share Posted April 30, 2021 A hack I figured out is to convert the strings to their UTF-8 code and add each array position plus and offset to get a unique number for each string. A benefit is that similar names are numerically close together. T Quote Link to comment Share on other sites More sharing options...
Alain2131 Posted May 2, 2021 Share Posted May 2, 2021 Hey Tim, What I'd do is do a for each loop with the name attribute as a piece Create a Meta Import, plug this into a wrangle, and use the iteration value as the unique value. If you just need unique values, that'll work. But if you need the value to be consistent with the names between the point clouds, it won't be. A side effect of this method is that it will sort the points based on the name. If you don't want the points to be reordered, you can do this instead, might be simpler. Note that this is slower with millions of points. Hope that helps ! uniqueValueByName.hipnc Quote Link to comment Share on other sites More sharing options...
tturner Posted May 4, 2021 Author Share Posted May 4, 2021 That's great Thx! T Quote Link to comment Share on other sites More sharing options...
Alain2131 Posted April 9, 2022 Share Posted April 9, 2022 Here's a revisit of this topic, with a better and simpler answer. The enumerate node does exactly what you need. It's fast, more than 10x faster than the wrangle method I used. (Maybe my code was not optimal, but that's another story) The result is the exact same as the wrangle, though. uniqueValueByName.hipnc 1 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.