How to numbering Surfaces by Z coordinate (MIN->MAX)

Could anyone help me to renumbering these surfaces by Z coorination order?(MIN->MAX)
Plus,is it possible to export the surfaces with these number and edges length to Excel files?
※Surface Number + Surface 3or4edges lengths
How to numbering by Z coordination.3dm (723.0 KB)

Hello- here is a quick Python that will name the surfaces in Z:

import Rhino
import scriptcontext as sc
import rhinoscriptsyntax as rs

def test():
    ids = rs.GetObjects(preselect=True)
    if not ids:
    geos = [rs.coercegeometry(id) for id in ids]
    cens = [geo.GetBoundingBox(True).Center.Z for geo in geos]
    dict = {cens[i]:ids[i] for i in range(len(ids))}
    cens = sorted(cens)
    for i in range(len(cens)):
        rs.ObjectName(dict[cens[i]], "Surface " + str(i))




Thank you so much for helping me.
Since I’m not familiar with Python Script component, Could you please share with Grasshopper file?

Hi Aida -

You posted your message in the Rhino category. The script that Pascal wrote is for Rhino, not Grasshopper. You can use it by running -_EditPythonScript in Rhino and pasting the script in that editor.

1 Like

OMG. I’m lost.
Nothing is changed.

Hi Aida -

If you run that and select all surface, then, yes, something will change. You’d have to select a single of those surfaces and check the Properties panel to see what changed, though. Pascal wrote:

[this] will name the surfaces in Z

If you want something else to happen, you will have to be more specific about your needs.

1 Like