Wish: Add a new "Time of last modification" property

Years ago, I proposed implementing of “Time of last modification” property to every type of object, so that the user could get a better idea which object is newer and which is older. Obviously, if a new object is not yet modified, the “Time of last modification” will be also the time of its creation. This could be especially useful in case that there are nearly duplicate surfaces with minor improvements on each iteration. :slight_smile:

Maybe a user key/value could be used?

Hmmm the date modified is the time when the file is modified :tired_face:

The expectation is that all newly created object in the future Rhino will have their unique “Time of last modification” (a value that could be updated upon every future modification of the object itself) which is not dependent of the file’s own modification time.

Yeah I got that but I already posted and who knows maybe this could be scripted somehow?

The best way is to have that information coded in Rhino itself, which means that the Rhino developers must implement it as a default properties.

If it was a script, I imagine that a Dot object could be automatically assigned to each new object and update the time value upon every modification. However, that would add an unnecessary amount of dot objects in the viewport consisting multiple objects. :slight_smile:

It could be Attribute User Text

So, it’s possible and just needs to be implemented soon. :slight_smile:

Copilot said it can be done with an event handler. In my example the script runs and updates whenever an object is modified. It’s just a test… It seems as if the key value pair is added to new objects automatically. Not sure how that works

import rhinoscriptsyntax as rs
import datetime
import Rhino

def update_modification_time(sender, e):
    """Event handler to update modification time of objects."""
    obj = e.ObjectId
    if obj:
        timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        rs.SetUserText(obj, "ModifiedTime", timestamp)

# Register event handlers
Rhino.RhinoDoc.ActiveDoc.AddRhinoObject += update_modification_time
Rhino.RhinoDoc.ActiveDoc.ReplaceRhinoObject += update_modification_time

print("Modification tracking script is running...")

Wow, so fast. This only works withing the current session, but can’t be saved and updated automatically when Rhino and the file is opened again later?

Rhino has an option to run a command when Rhino is started.

I put this line of code in there and now every new object has a timestamp.

Unfortunately I don’t see the command in this options panel the next time I open the file???

I use a few commands that way in Rhino 7. So, if this is added to the list of initially running commands, the time stamp will be preserved for the next sessions?

I closed and opened the file. This is in the command line:

File created in Rhino 9 WIP

timestamp.3dm (73.2 KB)

timestamp.py (564 Bytes)

Maybe it would be better to switch the script on with a command instead of having it run automatically?

I don’t have access to Rhino 9 WIP, but I will make sure to test this when I buy it once it’s released. :slight_smile: Thanks!

timestamp_8.3dm (78.4 KB)

You can put the script into a button and run it as a macro.

Thank you. I will try it tomorrow in Rhino 8.