How to filter schedules by Prefix "Pset_"?

Hello,

i did a simple collector so far… but how can i filter out schedules that start with “Pset_”

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

collector = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Schedules)
all_schedules = collector.WhereElementIsNotElementType().ToElements()

OUT = all_schedules

KR

Andreas

What have you tried so far?

psets = [i for i in all_schedules where i.Name.startswith("Pset_")] seems like a good place to start.

1 Like

@jacob.small ,

i am in cheat mode:

i will try it in python

@jacob.small ,

who the hell is “where” ?

what can i use instead… i use IronPython2

KR

Andreas

@jacob.small ,

look at that :wink: a one liner so “where” is in ironpython just “if” :slight_smile:

Psets = [i for i in all_schedules if i.Name.startswith("Pset_")]

KR

Andreas

2 Likes

Sorry - bouncing between 4 languages today and my python syntax was off when typing on the phone. :laughing:

Glad you’re sorted!

1 Like