Printing layer names automatically?

It will depend on what your curves are like - the script above does not have any error checking and will fail if you pick open or non-planar curves - because it will not find the centroid in those cases - so it returns None.

You can try the following modification which should work for open and non planar curves and see if it works:

import rhinoscriptsyntax as rs
curves = rs.GetObjects("Select curves", 4, preselect=True)
for curve in curves:
    layer = rs.ObjectLayer(curve)
    bb=rs.BoundingBox(curve)
    center=(bb[0]+bb[6])/2
    rs.AddText(layer, center, justification = 131074)
1 Like