Hi all, i want to make our companyworksets by using Dynamo. I’ve got help from AI gemini 2.0 Pro but there is a line not correct and giving a warning while not execute what i want.
NameError : name ‘Documentmanager’ is not
defined [’ File “”, line 22, in \n’]
I am getting the warning on this line: doc = DocumentManager.Instance.CurrentDBDocument
Importeer de benodigde Revit API libraries
import clr
clr.AddReference(‘RevitAPI’)
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *
doc = DocumentManager.Instance.CurrentDBDocument
workset_names = [
“50_SPA”,
“52_HWI”,
“52_VWI”,
“53_TWI”,
“55_KLI”,
“56_CVI”,
“57_MVI”,
“LF_BWK”,
“LF_CNS”,
“LF_ADV”,
“LF_ELT”,
“LF_XXX”
]
t = Transaction(doc, “Maak Worksets”)
t.Start()
existing_worksets = FilteredWorksetCollector(doc).OfKind(WorksetKind.UserWorkset)
existing_workset_names = [ws.Name for ws in existing_worksets]
for name in workset_names:
try:
# Controleer of de workset al bestaat
if name not in existing_workset_names:
Workset.Create(doc, name)
print(“Workset ‘{}’ aangemaakt.”.format(name))
else:
print(“Workset ‘{}’ bestaat al.”.format(name))
except Exception as e:
print("Fout bij het aanmaken van workset '{}': {}".format(name, e))
t.Commit()
Output
OUT = “Worksets aangemaakt/gecontroleerd.”
Maybe someone sees what i did wrong?
Thx in advance,
Regards Tim