Help on script, ElementType Name

Can someone please tell me why the first picture works (when the ElementType list is not in the same Revit script), but the second doesn’t?forum_2 forum_3

1 Like


What is your input, what is the output you expect and what are the errors you get ?

At the first glance, it seems to me that you are using your input in the first script but not the second.

In the first script, I am using the element_types = Filtered… as IN[0]. In the second script, element_types = … is already in the script, so ther is no input to this one. My goal is to have to liste, the fist one is a list of the element types in the document and the second the name of these element types.

this is what i want, but using the revit api instead.

Can you confirm you’re getting something with the filtered element collector?

If that’s not the issue, please post your code preformatted and/or your dyn so people don’t have to spend time typing up your python work in order to help you.

Out of curiosity, why not utilize the built in nodes?

1 Like

Home.dyn (3.8 KB)

I’m actually using dynamo to be sure the code works, after that I’m am going to create a macro.

The complete code is way longer than that. This is just the part that doesn’t works.

Gotcha. The filtered element collector is grabbing the correct elements as a structured list?

Yes, the most important thing is to be sure that the element type name is at the name index in the list as the element type is in his list (I’m creating a dictionnary later). Actually, the first code that works is exactly what I want, I’m just going to pass the Name attribute in a loop for and built a list of name with index that correpond.

*so index could correspond

Not sure why Name doesn’t work, but here’s what I did find out…
Using GetType() returns the ElementType that you already have.
Using FamilyName returns the family level definition.
You have to go through parameters to get the Type Name to find what you’re looking for.

import clr
from Autodesk.Revit.DB import *
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

element_types = FilteredElementCollector(doc).OfClass(ElementType).ToElements()
out = []
for type in element_types:
    name = type.GetParameters("Type Name")[0].AsString()

OUT = out