Creating and Renaming Worksets without Packages

Hello Dynamo forums

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.

If there aren’t any out of the box nodes then you’d have to use Python and the API.

1 Like

Hi Nick

Thanks for responding, sounds like this will be getting benched until I have learnt Python and thrown myself into the Revit API.

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.

Revit 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.

So… two questions here.

  1. Dis they get Revit 2025 deployed within a month of the first point release?
  2. 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 :stuck_out_tongue:

Workset Rename: Crumple

# 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)
Workset Create: Crumple

# 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)
2 Likes

Hi Jacob

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.

Hi Jacob

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.

Hi pyXam

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.

Hi pyXam

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.

Hard to say what the problem is without seeing what you are doing.
Try showing your progress so far using this as a guide.