This is my first post of 2025. Please see the below for context and task criteria.
Context
I am creating multiple Revit models from a custom template. Once the models have been created from the template work-sharing needs to be enabled and existing worksets renamed and new worksets created.
I want to be able to automate this with a Dynamo script that can be used through the Dynamo player within Revit. I am only able to use the native Dynamo nodes and cannot install any packages.
I have searched online and am unable to see a solution for this without installing packages.
Software Versions
Revit version - 2023
Dynamo Core - 2.13.1.3887
Dynamo Revit - 2.13.1.3891
Task
The script should do the following once it is run through the Dynamo player.
Enable worksets
Specify the new workset names to be created
Specify the default worksets to be renamed
Specify the updated workset names
Thanks in advance and look forward to hearing from you.
This is rather problematic - whatâs the reasoning?
I did a quick analysis on my âplaytimeâ environment that I use for all the things, and found that more than 3/4 of my library came from outside the core environment. Youâre basically saying "were going to use 1/4 of the tools and add years of technical debt to everything we do because âno packagesâ.
Really pretty simple.
FilteredWorksetCollector to gather worksets. Get the names. Change he names. Add some new ones.
A handful of lines of code. A good project to start learning the API.
As far as packages. I get it. Our office has outsourced IT. Absolutely everything has to be manually âpermittedâ to run. (They tried to install a new version of VRay for 3ds Max - over 60 error dialogs of dllâs that werenât allowed to run, Still not working yet.). So getting additional packages to run - a big effort. I fly under the radar with the API.
Dis they get Revit 2025 deployed within a month of the first point release?
Has someone done an analysis of the impact of this locked down environment on development and deployment efforts yet and made a business case?
I.e.: âWe decided to outsource IT and go into this locked down environment because it saved us money (in house IT and cybersecurity insurance costs). However our development efforts with things like Dynamo are now bottlenecked, meaning staff is continually re-inventing wheels which our competition just gets to consume from public sources. That costs is $X/year in lost productivity and deployment efforts, as well as adds $Y/year of maintenance and upkeep, further delaying deployment efforts for annual product releases.â
When Inhave seen this done the outsourced IT suddenly gets a lot more capableâŚ
Three words: âGovernment Military Contractsâ
The requirements are over the top. Doesnât matter if weâre Lockheed working on some Skunkworks system. Or a warehouse for trucks. These warehouses designs get the same security as a nuke stealth hypersonic whatever.
Revit rollouts are slow. Weâre just now seeing 2025 projects. Government is always way behind in versions. Corp fo Engineers were requiring 2018 for the longest time. Not that they ever open a Revit project.
So, I donât do a lot of the government stuff. Not much design work there. But it impacts our private sector work.
I guess the only good news is that we get new hardware regularly to meet all the UIEF and TPM, etc, etc⌠(Those new Intel chips suck.) But - yes - things get nuts. We installed a new phone system. A month or two after that - we pulled the whole thing out, because it had Chinese parts in it. Now weâre all on Teams VOIP and our cell phones. No phones at the desk. Iâm not sure that is a big step forward in security.
Iâve stepped away from a whole bunch of tech I was suing for design, like Unreal and Steam (yep - VR) Just too much for a smallish IT company to keep pace with.
Now Copilot is all over MS OS and apps. That will be a security nightmare.
This is the only reason to block stuff, but itâs a small segment of Dynamo uses overall, and those contracts can carry a development budget.
But all the other jobs, which donât need the security and have tons of value, are usually left in another environment (have seen remote log-in work great for this).
You donât need to bench it.
I can pull the python from the Crumpl package already on the package manager so you donât need to install it to get the python you are looking for.
Everything that you mentioned above is Scriptable but i suggest starting the process for now by manually enabling worksharing and then proceed with the Workset scripts.
When you have those down, come back for the Workset enabling
# Made by Gavin Crump
# Free for use
# BIM Guru, www.bimguru.com.au
# Boilerplate text
import clr
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import WorksetTable
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Define list/unwrap list functions
def tolist(input):
result = input if isinstance(input, list) else [input]
return result
def uwlist(input):
result = input if isinstance(input, list) else [input]
return UnwrapElement(result)
def objOrList(input, initial = IN[0]):
if isinstance(initial, list):
return input
else:
return input[0]
# Current doc/app/ui
doc = DocumentManager.Instance.CurrentDBDocument
# Preparing input from dynamo to revit
wkst_ele = uwlist(IN[0])
wkst_nam = tolist(IN[1])
# Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
bools = []
for w,n in zip(wkst_ele, wkst_nam):
try:
WorksetTable.RenameWorkset(doc, w.Id, "__" + n)
WorksetTable.RenameWorkset(doc, w.Id, n)
bools.append(True)
except:
bools.append(False)
TransactionManager.Instance.TransactionTaskDone()
# Preparing output to Dynamo
OUT = objOrList(wkst_ele), objOrList(bools)
# Made by Gavin Crump
# Free for use
# BIM Guru, www.bimguru.com.au
# Boilerplate text
import clr
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import FilteredWorksetCollector, WorksetKind, Workset
# Current doc/app/ui
doc = DocumentManager.Instance.CurrentDBDocument
# Define list/unwrap list functions
def tolist(input):
result = input if isinstance(input, list) else [input]
return result
def objOrList(input, initial = IN[0]):
if isinstance(initial, list):
return input
else:
return input[0]
# Preparing input from dynamo to revit
new_names = tolist(IN[0])
worksets_out, bools = [],[]
# If document is workshared...
if doc.IsWorkshared:
# Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
# Collect workset names
worksets = FilteredWorksetCollector(doc).OfKind(WorksetKind.UserWorkset).ToWorksets()
ex_names = [w.Name for w in worksets]
# For each workset...
for n in new_names:
if n not in ex_names:
workset = Workset.Create(doc, n)
worksets_out.append(workset)
bools.append(True)
else:
worksets_out.append(None)
bools.append(False)
# Close transaction
TransactionManager.Instance.TransactionTaskDone()
# Otherwise we return nothing
else:
for n in new_names:
worksets_out.append(None)
bools.append(False)
# Preparing output to Dynamo
OUT = objOrList(worksets_out), objOrList(bools)
Just a bit of content, I am working in an environment that does not allow me to freely download and install software. Acquiring additional software/plugins/packages/updates/hotfixes that are no in the software catalogue has a lead time 6-12 months if not more.
I am trying to build as much as I can with the Dynamo core functionality. I am realising this isnât sustainable, I think learning Python will be the answer so I can create my own nodes and scripts. This should resolve all of the issues I am facing.
Hi Aaron
I am planning to do the same thing an learn Python and the Revit API. My focus is drawn somewhere else at the moment and will peruse my coding and API goals next.
My team has tried to build a case for acquiring new software etc but the environment we work in will not allow it without a very long acquisition time to review each piece of software and itâs integration with the system. It took almost 2 years for Revit to be acquired before we could even start modelling. This is a very unique situation and is not a traditional design environment.
Thanks for your reply this is great, this should speed things up enough for now to save a great deal of time. Iâll be sure to come back for the Workset enabling help.
I have managed to find the time to keep going with this script and thought Iâd give you an update. I have managed to create the scripts and learnt how to import the code into a Python node.
The script to create new worksets is working great, but the worksets being renamed are returning false values. I have attempted to change the way I am inputting my values with no luck.
I am planning on allocating time towards enabling the worksets soon.