A script question

Hi,

A script question. After I select an object, specify that the object uses the system’s current time to name the object and then copy it into a layer hidden. Each time the implementation of the script will perform the above operation, and now there are many objects inside the layer, I would like to select the last time the name of the object display to the current default layer. Is the object name in the layer sorted? How do I read the name of the last time after sorting?

This the python code:





def FilletObjWithDateTime():


    date = time.strftime(date_format, time.gmtime())
    tnow = time.strftime(time_format)

    msg="Select Object name by layer"
    objid = rs.GetObject(msg,preselect=True,select=False,subobjects=False)
    if objid:
        rs.ObjectName( objid, str(date)+str(tnow) )
        

FilletObjWithDateTime()

Dunno, does this help any?

import rhinoscriptsyntax as rs

layer_objs=[(rs.ObjectName(objID),objID) for objID in rs.ObjectsByLayer("FilletObject")]
layer_objs.sort(reverse=True)
print "Last object ID={}, Object name={}".format(layer_objs[0][1],layer_objs[0][0])

I assumed reverse sort for the highest number to be first, I think that’s the latest date/time…

–Mitch

wow, Thanks.
It works well. Best!