How to automatically extract mesh ID number and print as text?

Hey guys,
I’m searching for a way (via scripting or Grasshopper) to automatically extract mesh IDs as text and position it beside the corresponding mesh.

This is my actual situation:

  1. I extract UVs with the _UVEditor command

This is what I’m trying to achieve:
2) Inspect every mesh via script and create a text box beside the corresponding mesh containing the relative mesh ID (the number inside the brackets)

Is it possible in Grasshopper or via script?
Thank you very much for your help,

I’m not sure what that number is inside the (). I thought it would be the object table index but quick experiment shows it probably isn’t. However, the other part is the GUID in rhinoscript/common, which is readily available. You could also assign custom identifiers with user text. The trickier part is to layout the meshes and text items for readability.

Also look at the ExtractUVMesh command for making the document meshes (I don’t think you can extract from the UVEditor directly)

The IDs will probably change every time they are extracted, so don’t depend on them to persist through multiple extractions.

Hi @Julio,

The value you’ve highlighted is the object’s runtime serial number. Here is how you can obtain it using Python:

import Rhino
import rhinoscriptsyntax as rs
obj_id = rs.GetObject("Select object")
if obj_id:
    obj = rs.coercerhinoobject(obj_id)
    id = obj.Id.ToString()
    sn = obj.RuntimeSerialNumber.ToString()
    print('Id: {0} ({1})'.format(id, sn))

– Dale