1: 过滤所有的工作集
FilteredWorksetCollector col = new FilteredWorksetCollector(doc); _AllWorksetList = col.Where(p => p.Kind == WorksetKind.UserWorkset).OrderBy(p => p.Name).ToList(); foreach (Workset ws in _AllWorksetList) { checkedListBox1.Items.Add(ws.Name); _SumCount++; }
2:过滤工作集中的所有元素
foreach(Workset ws in wsList) { FilteredElementCollector col = new FilteredElementCollector(doc); ElementWorksetFilter fil = new ElementWorksetFilter(ws.Id); ICollectionwsElements = col.WherePasses(fil).ToElements(); eList.AddRange(wsElements); }