Python to get scripts usage informations in your company

Hi all,
I am developing a workflow in order to monitor and track the scripts usage from all of the offices of the company where I am working for, here in Italy. I think it will be really useful to see how many times the scripts are used, from who and when.

In the next months you could create some dashboards to analyze those data, maybe combined with other data sets and do your “data analysis” and observations.

The code started from the @john_pierson one, then I’ll added a couple of things.

We are currently using still Dynamo 1.3 and obviously I know it could be done in better ways, but I’ve just started coding like 10 days ago :space_invader: and this code it’s working for me at the moment. If there are improvements you think I could include, please feel free to tell me :pray:

Stop talking, here is the code: :sunglasses:

# ---------------------------------------------------------------------- CREDITS




__author__ = "Ernesto Pellegrino -"

__twitter__ = "@aitenlabs"

__linkedin__ = ""

__version__ = '1.0.0'


This code started from the John Pierson (twitter @60secondrevit) one in order to obtain the dynamo workspace name.

I've added the username, the date and the time informations.

Please note that the date and time outputs might vary based on your own PC settings.


# ---------------------------------------------------------------------- IMPORTS & REFERENCES

import clr


import Dynamo


import DSCore

from DSCore import *


from RevitServices.Persistence import DocumentManager

# ---------------------------------------------------------------------- DATA

# access to the current Dynamo instance and workspace

dynamoRevit = Dynamo.Applications.DynamoRevit()

currentWorkspace = dynamoRevit.RevitDynamoModel.CurrentWorkspace

dynamoFileName = currentWorkspace.FileName

# get the user

app = DocumentManager.Instance.CurrentUIApplication.Application

userName = app.Username

# get the current date and time

Now = DSCore.DateTime.Now

Day = DSCore.DateTime.DayOfWeek(Now)

Date = Now.ToString()[:10]

Time = Now.ToString()[11:16]

# ---------------------------------------------------------------------- OUTPUT

# output the username, the Dynamo Workspace name, the date & time

OUT = userName, dynamoFileName, Day, Date, Time

This is the custom node you can use
aitenlabs.GetUserAndWorkspaceInformations.dyf (11.8 KB)


Good job! :slight_smile:

1 Like

Here is something similar from a previous discussion.
Sending emails

1 Like

@Ernesto_Pellegrino have a look at the code on the below link. It was some python code started by @john_pierson which i updated to allow it to work for dynamo 1.3 and 2.0.

You could use the dynamo version it is getting to output that as part of the usage info :slight_smile:

Also if your scripts are generally used by revit it may be worthwhile getting the revit version/build and revit file info(file size, name and link info) to get the full extent of usage information?


I’d focus on which project used it rather than which user used the script. So I’m pulling project number & project name parameters as well to generate script use per project. here is the code for that…

collector = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_ProjectInformation).ToElements()

and for the username, I’m not using Revit Username, I’m using the username from OS.


Well done @jalshu, thanks for sharing!