I am reading data in from CSV text file where each line in the file is a distinct record. In that record is the name of a text style which I need to convert to the elementID of a TextNoteType.
I have a FilteredElementCollector to get a list of all text styles (as shown below) but what I need to do is pull an elementID from that based on the style name. I would rather not use a loop for that but something like a Python dictionary. For example: A = StyleList["stylename"]
Looking at this code snippet from Revit Python Shell:
ListOfTextStyles = FilteredElementCollector(doc).OfClass (TextNoteType)
a = ListOfTextStyles.ToElements()
a.Item
When I get to the point of typing "a.item" I see the following which suggests an indexer might be available to do what I want but I do not quite understand how...
Is it possible to do something like: a(property = "type name")["style name"] to get a TextNoteStyle element?
Michelle
Look at the definition of the FilteredElementCollector class. It is a generic collection of
Element
. So, an automatic indexer is available, andItem
presumably returns anElement
. If the current element is aTextNoteStyle
, you can cast it to such and use its methods.Sorry, I missed the (unnecessary) call to
ToElements
. Similar arguments apply there; it returns a genericList
ofElement
.However, there is mostly no need for the
ToElements
method. You can just leave it away. Doing so may even save memory and improve performance.This question was also raised and discussed in the Revit API discussion forum thread on Indexer and FilteredElementCollector.