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()
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 ).