WallType.Name, Not working, missing something simple

I must be missing something very simple. I have attached the very simple Dyn file for your review.
In the code below the left most Python Node in the attached file, I have commented out the code to i.Name as it fails. But, when the same code is in a second node it works? Hence the second node in the attached file. Why would this be? I tried using a transaction, but it did not work. I tried on a second computer same issue. I must be missing something fundamental…

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

# Revit API
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument

mylist = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsElementType().ToElements()

output = []

for i in mylist:
    x = i#.Name
    output.append(x)

OUT = mylist#, output

Issue.dyn (5.2 KB)

Can you show a screenshot of the graph in action (with all node preview bubbles visible) and both sections of python code? That will make things much quicker and ensure there are no other issues with dependencies or conflicts on anyone else’s end.

1 Like

Here is it working as two nodes,

Here is the first node where i.Name errors

Note that the goal is to do it all (get the WallType Name) in the first node with no second node needed. I only added the second node for testing, and oddly it works as two nodes but not as one. In the more macro this issue came about in a much larger application of trying to use the WallType.Name, then I distiiled the issue to the question above.

I don’t have time to troubleshoot now unfortunately, but it looks like i.Name should work. I can’t say why it’s specifically not working in the first case, but the reason it’s acting differently is likely because you have different object types between the two python nodes. In the first node, you have the Revit Elements. Returning that list of elements at the end of the python node automatically wraps them back into Dynamo Elements. You could use the parameter value for Type Name instead of the Name property or you could dig deeper into why this doesn’t seem to be working in the first place.

1 Like

This does work, but I dont understand the original issue.

for i in mylist:
x = i.get_Parameter(BuiltInParameter.SYMBOL_NAME_PARAM).AsString()
output.append(x)

The reason you’re getting two different results is because you’re using two different methods on two different object types. The first node uses the Revit API property Name on the Revit objects. The second node doesn’t have the Revit API loaded and uses the Name property from Dynamo on the Dynamo objects.

However, that doesn’t explain why the Revit elements aren’t finding the name from the Revit property.

1 Like

For whatever reason the get_Name() method works.

2 Likes

Hi,
FYI, I wrote an article about this

use the translate button if necessary

3 Likes

Cyril to the rescue!

1 Like

Thank you for the article! This helps.

1 Like