Thank you. For now seems that this algorithm have some issues sorting mixed numbers and text names.
CustomSortCumberlandPairs (1).gh (19.7 KB)
Sort_Test.3dm (8.9 MB)
Thank you. For now seems that this algorithm have some issues sorting mixed numbers and text names.
CustomSortCumberlandPairs (1).gh (19.7 KB)
Sort_Test.3dm (8.9 MB)
That seems to be a consequence of passing Breps through the sort component. If instead you pass the Name extracted via the first RhAtt component you get the missing values:
I don’t know why there is a problem with the Breps. It isn’t the way the sort routine processes them - if I output the input Values unsorted then the second RhAtt still outputs nulls:
Regards
Jeremy
I’ve done a little more investigation into your null issue. I replaced the Elefront components with the new Object component in the Rhino 8 Beta and that resulted in a full list with no nulls:
I think you need to take the null issue up with the Elefront people.
Regards
Jeremy
Hi all,
I explained in more detail in this reply but to add to the conversation here:
As the objects pass into and out of the python component, they are losing their reference to the original object. You can see it no longer says “Referenced”, and it does not have a GUID.
The fact it does work sometimes I would consider more of a fluke, and best practice would be to make sure the reference is being passed through in a robust way.
I am doing furniture mechanization, and I do need to generate cutting-lists and group the parts based on Names, Layers or different Attribute User Text Keys/Values do they have associated.
Sorry to wake-up again this thread but I just found a bug into this sorting script. Looks like in this particular situation the script it is not sorting the names at all. It is possible to fix-it?
Sort.gh (9.5 KB)
Hi @Cumberland,
That isn’t a bug: you are using a different data format from before. As I said in a previous post
Here is a version modified to work with the numeric suffix.
Regards
Jeremy
I posted these awhile back - perhaps they are of use?
natural_sort_v7.gh (7.2 KB)
natural_sort_v8.gh (5.0 KB)
– Dale
This also looks good unfortunately they don’t have an option to also sort the corresponding GUIDs. Myself I do need to sort the BREPs GUIDs based on the name of the BREPs. Or maybe al least to have an additional output with the new index order of the sorted names so I can use that index to sort my BREPs. Thank you.
import re
def natural_sort(l):
convert = lambda text: int(text) if text.isdigit() else text.lower()
alphanum_key = lambda key: [convert(c) for c in re.split('([0-9]+)', key)]
return sorted(l, key=alphanum_key)
a = natural_sort(strings)
b = natural_sort(index)
I took a look into the code of the Natural sort component and I am thinking that maybe will be possible to also sort the order of the indexes and print the result at output b. Please help if somebody knows how to do this. Thank you.