Asign Active Workset

Hi, I would Like to know if there is a way to set Dynamo as an Active Workset.

I was looking I could see that there is an option with the Id of the Workset but I can not find a Node or a method in python to do it, Thank you.

I would like to control it for future Scripts for my Team, If I can get access to the data about the Workset that is assigned .

image

Yes you can get the worksettable from the active document, then set the workset that is active by Id:

Method to get workset table from document:

Method to set active workset by id for worksettable:

The same, but to get the workset:

Thank you GavinCrump, It is a good Started :grin:

1 Like

Here’s the code to set it as well, had to get to a computer…

# 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 *

# Current doc/app/ui
doc = DocumentManager.Instance.CurrentDBDocument

# Get the workset as input
ws = IN[0]

# Get workset table
table = doc.GetWorksetTable()

# Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)

# Try to set the workset
try:
	table.SetActiveWorksetId(ws.Id)
	OUT = True
except:
	OUT = False

TransactionManager.Instance.TransactionTaskDone()

set workset.dyn (11.3 KB)

That is Perfect it is what I wanted.Now I can continue with my Script, the goal of it is to bring it to C# to the macro editor.

But I do not know exactly do the macro run when I open a file(Just what I can do it when I open Revit, close or run a macro ), I want that the macro editor set a workset depending on the user name (all this is controlled ).

I wanted to add a Module as the Module _Startup but I tried to do the same in the Internal Startup adding the Initialize method.

Is something that you can help or should I open a new topic?

Thank you Very much in advance

That’s one to ask over on the revit forums.