This post is about collecting element’s worksharing information from a central model by using Ironpython in Revit Dynamo Application.
First to import the modules: clr to load .Net Assemblies as IronPython modules : RevitAPI.dll for DB, RevitServices.dll for DocumentManager and TransactionManager. Collect the current document and store in doc variable.
# dynamo version - 1.3.4
import clr
clr.AddReference('RevitAPI')
clr.AddReference("RevitServices")
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
# the current document
doc = DocumentManager.Instance.CurrentDBDocument
And create output lists, you will notice that each list contains a value which is the title of each Excel column. And then append associate data to each of the list.
# create output properties values list
status, elementids, categories, ftypes, creators, owners, lastchangers =
["Status"], ["ElementId"], ["Category"], ["FamilyType"],
["Creator"], ["Owner"], ["LastChangedBy"]

Next step, loop through the input element(s) and collect the information. WorksharingUtils class contains utility methods for element’s worksharing data. Collect element’s information in the central model by using GetWorksharingTooltipInfo method with two arguments (element’s document & element’s Id).

# input elements
elems = UnwrapElement(IN[0])
for e in elems:
# element's doc
c_doc = e.Document
# get worksharing info
wsu = WorksharingUtils.GetWorksharingTooltipInfo(c_doc,e.Id)

GetWorksharingTooltipInfo method returns WorksharingTooltipInfo object which contains element’s Creator, LastChangedBy and Owner properties.

GetModelUpdatesStatus method returns ModelUpdatesStatus enumeration which indicates whether an element in the current model has additional user changes in the central model.
# get element status in model
status.append(WorksharingUtils.GetModelUpdatesStatus(c_doc,e.Id))


Finally, collect element’s property/information : ElementId, Category, FamilyType, Creator, Owner, LastChangedBy and append to its associate output list.
# append properties values
# get element Id
elementids.append(e.Id)
# get category name
categories.append(e.Category.Name)
# get family type
ftypes.append(c_doc.GetElement(e.GetTypeId()))
# get element's creator
creators.append(wsu.Creator)
# get current owner
owners.append(wsu.Owner)
# get last changer
lastchangers.append(wsu.LastChangedBy)
# output lists
OUT = status, elementids,categories,ftypes, creators, owners, lastchangers
Sample usage, output result and the complete code is below.


# dynamo version - 1.3.4
import clr
clr.AddReference('RevitAPI')
clr.AddReference("RevitServices")
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
# the current document
doc = DocumentManager.Instance.CurrentDBDocument
# create properties values list
status,elementids,categories,ftypes, creators, owners, lastchangers =["Status"], ["ElementId"],["Category"],["FamilyType"],["Creator"],["Owner"],["LastChangedBy"]
# input elements
elems = UnwrapElement(IN[0])
for e in elems:
# element's doc
c_doc = e.Document
# get worksharing info
wsu = WorksharingUtils.GetWorksharingTooltipInfo(c_doc,e.Id)
# append properties values
# get element status in model
status.append(WorksharingUtils.GetModelUpdatesStatus(c_doc,e.Id))
# get element Id
elementids.append(e.Id)
# get category name
categories.append(e.Category.Name)
# get family type
ftypes.append(c_doc.GetElement(e.GetTypeId()))
# get element's creator
creators.append(wsu.Creator)
# get current owner
owners.append(wsu.Owner)
# get last changer
lastchangers.append(wsu.LastChangedBy)
# output lists
OUT = status, elementids,categories,ftypes, creators, owners, lastchangers
Screenshots from https://www.revitapidocs.com/