Hi. I wonder if anyone can help with writing a revit workset into a WORKSETID parameter? I’m thinking that if I wanted to schedule entities using this WORKSETID as a filter, would it have to be a shared parameter as well? Thanks in advance!
Are you looking to get WorksetID from Elements and Write that ID into another parameter?
Doesn’t have to be unless you want to use that parameter in tags.
Hi Kulkul. I’m trying to schedule strut or trapezes that support lighting, cable trays, conduits, etc. So in order to create a schedule that looks only at struts/trapezes that are in the lighting workset, or the cabletray workset, or the conduit workset, I have to use the WORKSETID to hopefully allow me to schedule these trapezes separately, based on their workset. Hopefully that’s clear. Thanks!!
I’m trying to assign WORKSETID to the trapezes, so I can schedule them separately, based on which workset they are being used in.
Regarding to the shared parameter - probably not. I’m only using it as a filter in my schedule.
You could do it like this:
import clr #Import the Revit API clr.AddReference('RevitAPI') import Autodesk from Autodesk.Revit.DB import * #Import DocumentManager and TransactionManager clr.AddReference('RevitServices') import RevitServices from RevitServices.Persistence import DocumentManager #Reference the active Document and application doc = DocumentManager.Instance.CurrentDBDocument #Start scripting here: def wsName(worksetid): res =  if not isinstance(worksetid, list): wsid = WorksetId(worksetid) res.append(doc.GetWorksetTable().GetWorkset(wsid).Name) else: for i in worksetid: res.append(wsName(i)) return res #Assign your output to the OUT variable. OUT = wsName(IN)
You could get the WorksetId aswell as the name, but I just think the name will be easier to understand if other people in your organisation where to use the data :-). The WorksetName parameter is just a project text parameter, and can be scheduled:
If you just want the ID, then just skip the python part and create an integer parameter instead of text parameter, or convert the output of the Element.GetParameterByName to a string.
Thanks, Martin! I appreciate you taking the time to whip one up!!