All elements on workset

Hello,

can i get all elements of these worksets starting with a FilteredWorksetCollector ?

import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument


# 🌈 all Worksets
collector = FilteredWorksetCollector(doc).OfKind(WorksetKind.UserWorkset)

names = [i.Name for i in collector]
ids = [i.Id for i in collector]

OUT = []
for i,d in zip(names,ids):
    OUT.append("{} - {} ".format(i,d))


KR

Andreas

Hi, Element class has a property

edit:
Look at the exemple 3 (blog by c. Poupin top quality as usual)

Cordially
Christian.stan

2 Likes

@christian.stan ,

i am one step closer :wink:

collector = FilteredWorksetCollector(doc).OfKind(WorksetKind.UserWorkset)

names = [i.Name for i in collector]

worksets = collector

OUT = []

for workset in worksets:
	elementWorksetFilter = ElementWorksetFilter(workset.Id)
	fecbyWksetId = FilteredElementCollector(doc).WherePasses(elementWorksetFilter).ToElementIds()
	#selectElemId = uidoc.Selection.GetElementIds(fecbyWksetId)
	OUT.append(fecbyWksetId)



KR
Andreas

1 Like

@christian.stan ,

i think this is right a get list of list so i have to check if it is realy sorted by worksets !

for workset in worksets:
	elementWorksetFilter = ElementWorksetFilter(workset.Id)
	fecbyWksetId = FilteredElementCollector(doc).WherePasses(elementWorksetFilter).WhereElementIsNotElementType().ToElements()
	#selectElemId = uidoc.Selection.GetElementIds(fecbyWksetId)
	OUT.append(fecbyWksetId)

This is the purpose of the filter
at the same time :wink:

cordially
christian.stan

1 Like

@christian.stan ,

i just have to handle None Elements


KR
Andreas

1 Like

I’m expected, I’ll leave you, have a good quest and evening in the elimination of empty :wink:, for my part I’ve been trying to understand the events for several days (it’s very hard for my little head)
cordially
Christian.stan