Hi,
I’m trying to write a simple Python code that will prompt me rhino file summary information, such as the creation date, last save date, revision number, and by whom the file was created, but without opening the file. Is this possible? If so, what should be the method?
Thanks.
Hi @jllibera,
Does this help?
#! python3
import Rhino.UI as ui
import Rhino.FileIO as io
def Read3dmFileProperties():
fd = ui.OpenFileDialog()
fd.Filter = "Rhino 3D Models|*.3dm||"
if not fd.ShowOpenDialog():
return
rc, createdBy, lastEditedBy, revision, createdOn, lastEditedOn = io.File3dm.ReadRevisionHistory(fd.FileName)
if rc:
print("File name: {0}".format(fd.FileName))
print("Created by: {0}".format(createdBy))
print("Created on: {0}".format(createdOn))
print("Last edited by: {0}".format(lastEditedBy))
print("Last edited on: {0}".format(lastEditedOn))
print("Revision: {0}".format(revision))
if __name__ == "__main__":
Read3dmFileProperties()
– Dale
Thanks a lot Dale,
and do you think it is possible to write this script so it will work independently from Rhino, allowing it to check the Rhino files without opening the 3dm files themselves? I’ am trying to write it with chat gpt support, but until it fails.
Best
Jan
You can use rhino3dm
(rhino3dm · PyPI) in regular python. Here a run in the Python REPL in a shell on MacOS:
>>> import rhino3dm as r3d
>>> m = r3d.File3dm.Read('/Users/jesterKing/Documents/3dms/objects_and_annotations.3dm')
>>> m.CreatedBy
'Nathan Letwory'
>>> m.Created
datetime.datetime(2024, 6, 5, 14, 55, 44)
>>> m.LastEditedBy
'Nathan Letwory'
>>> m.LastEditedBy
m.LastEditedBy
>>> m.LastEdited
datetime.datetime(2024, 6, 6, 4, 38, 22)
>>> m.Revision
4
>>> m.ApplicationDetails
'Commercial, build 2024-06-03'
>>> m.ArchiveVersion
80
>>> m.ApplicationName
'Rhinoceros 8'
>>>
1 Like