Sort list of geometries by name

I do need to create some keys/values for some geometries that I do have imported from Rhino into Grasshopper and I do need to sort the list of geometries by prefix number in the order 00, 01, 02 up to the end of the list and grup the items with the same prefix number by branches if there are more geometries sharing same prefix number.

My imported list of geometries looks like this:

For example, I do have four geometries sharing the same name with the prefix number of 01, for nr. 02 I do have only two geometries, etc.

It would be useful if you shared the .gh file but seems like the “Sort List” component would do exactly what you’re saying.
-Dani

1 Like

If I connect the Breps to the K input of the SortList component the output K generates only <null>

Geometry_sort_by_name.gh (10.8 KB)
Geometry_sort_by_name.3dm (2.8 MB)

not sure if this is what you need:

Geometry_sort_by_name_02_tp.gh (11.4 KB)

1 Like

For some reason my version of Elefront didn’t like your component to get the attributes, and even though I was trying to install it it just didn’t want to, so I just replaced it with mine, which seems to work fine as well.
The problem with “Sort List” is it only take numbers as input. Using the “Text Fragment” component it is possible to get the numbers of the layers and everything works fine:

Perhaps this link will help you understand further how the “Sort List” component works. Also, I believe there are other entries in this forum talking about the functioning of this component.

Geometry_sort_by_name.gh (20.7 KB)
Geometry_sort_by_name.3dm (2.8 MB)

-Dani

Thank you very much. It is working as expected.

There are three diferent versions of Elefront right now. It is the 5.0 beta, the 4.3 and the 4.2.2, if I remember correctly. On the food4rhino website it is explained the current situation of the plugin. Personally I do have two versions installed on my system.

1 Like

Dear @Macuso
if you want the geometrie / breps be sortet as well - just pass them as values - and handle the tree with the same “replace paths”…
see attached .gh file

Geometry_sort_by_name_03_tp.gh (16.2 KB)

1 Like

Late to this party because I’m trying to integrate this with the OpenNest work eight days ago but failing so far. OpenNest is hung. :frowning: OH! 3.3 million pieces, that’s not right!

Here’s what I did for this thread, using Python instead of Elefront to get the names.

import Rhino
import scriptcontext as sc

sc.doc = Rhino.RhinoDoc.ActiveDoc
name = sc.doc.Objects.Find(geo).Name


sort_by_name_2022Oct9a.gh (23.8 KB)

And here’s the integration with OpenNest:



sort_by_name_2022Oct9bb.gh (35.1 KB)

1 Like

It occurs to me that you don’t need to sort by name in order to group (branch) by name, because CSet (Create Set) works with strings.


sort_by_name_2022Oct9c.gh (23.7 KB)

P.S. In fact, instead of ‘Name’ you can use sum of edge lengths (or face areas?) as a unique ID:


sort_by_name_2022Oct9d.gh (21.6 KB)

I need to use the Names of the objects because I do receive them numbered like 01, 02, 03 … and also a cutting list with a bunch of details about each object, like material used, edging, what kind of mechanisation will be applied, etc. and I am using this kind of Grasshopper definition to create a mach between the 3D objects and the information from the cuttinlist to generate the needed Keys/Values for each object.

I am using this after running the EasyCut script, and instead of manually entering all the details, I just run a script that populate all the information for me and sort in layers by material used.

EasyCut, for some reason it is unable to read the names&numbers of the objects, so needs to be entered manually.

You got that in sort_by_name_2022Oct9bb.gh and sort_by_name_2022Oct9c.gh. You’re welcome.

1 Like

This is how this unit looks before running the EasyCut script:

After running the script it is populating every object with a bunch of Keys/Values, accourdingly.

One big issue it is the fact that it is recognizing three different panels (09-SIDES & DIVISION PANELS TOP ADD ON’S, in my file below) as being the same, even if I do need to apply sightly different mechanisation to each of this panels.

Unfortunately the script wasn’t upgraded in the last two years and seems that the original developer abandoned this very useful project in GitHub so, (until somebody will want to continue his work) I am trying to develop further his ideea using GH definitions to make-it usable for my needs. Still are some issues I can’t overcome right now, like, for example, the lack of explicit edging, so, for example if I have only one edge aplied on the Length of the piece, I can’t specify in which edge (front or back) will be the edge applied. Also I am mechanizig some pieces like doors with glass inserts who also needs to have edges applied inside, which information I can’t specify right now in Spec.

One big issue still remains regarding to OpenNest: After nesting, I would need to find a way to mark the edges of the pieces that will have edges applied to them as I do need to mark that faces with a marker after cutting the pieces and I need to find a way to create automatically a layer called “Edging” that will have applied a red line on top of each edge of the panel that needs edging. So, when I do print the layout of the nest I can have a birds eye view where the edging will be applied to be able to mark that edges after the CNC cutting process.

EasyCut_edges.3dm (2.7 MB)

I’m not interested in the EasyCut script. My contributions to your threads have been general purpose that others might find useful. I see in the Rhino file you just posted (EasyCut_edges.3dm) that the same list of attributes has been applied to all geometry with values all set to ‘0’.
EasyCut_2022Oct9a

What I haven’t seen is any identification marks (or Names) being passed to OpenNest, so it’s not clear how you’ll know which pieces are which? That also seems like an important detail?

This it is how looks the Keys/Values after applying some GH definition that reads and matches the information from an .xslx file with numbers of the object names from the Rhino file:

EasyCut_after_GH.3dm (2.7 MB)

I selected all visible pieces in your EasyCut_edges.3dm file for the OpenNest treatment and immediately saw flaws due to unattached edges in your Rhino file. This image shows one selected but there are many. How did that happen? I could add some clutter to my GH file to ignore those pieces but that’s janitorial work (garbage cleanup).

On closer inspection, they appear to be edge trim pieces with some thickness, not just unattached faces. My code tries to orient the pieces flat for OpenNest but clearly fails with these shapes.

The selected edge piece is named “10-R/H & L/H SHELF EDGING[1]”. Tricky!!

I don’t select all objects from the file to nest. Before nesting I do sort the pieces by material, I do put them on layers, I do select pieces by layer and only after that I do nest. The edges are there only for visual representation.

In this example I do pass in OpenNest only the pieces that are into the “18Black” layer.

As I do explained in my previous post, after cutting the nested objects I do need to mark the edges of the pieces where the edging will be applied into the next step of fabrication.

Maybe there is a way to reassociate this 2mmEdges with the 18Black pieces AFTER the nesting process of the 18Black pieces. This way I can quikly locate that edges on the nested sheet to mark them.

Is the ‘ColorB’ node a python script?

OK, much better. Wish I’d known that earlier, I would have used a Geometry Pipeline like this:


sort_by_name_2022Oct9e.gh (31.8 KB)

1 Like

No, it’s a cluster. You can open it and see how it works. Assigns each branch a different color.