Get Shared Type Parameter value from multiple elements

Hi all,

I am trying to get the values of one type shared parameter from multiple elements. But I am doing something wrong.

It seems to be a problem with the lookup.
What am I doing wrong?
Or is there any other way of doing it without lookup?

import clr

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

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

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

elements = UnwrapElement(IN[0])
values = []

for element in elements:
    value = elements.LookupParameter('Code').AsString()
    values.append(value)
    
OUT = values

Hi @aafonsoBYKA8,

You made a typo.
It should be element and not elements.

for element in elements:
    value = element.LookupParameter("Code").AsString()
1 Like

true! but still…

Maybe :

for element in elements:
    value = element.LookupParameter("Code").AsValueString()

It depends of your type of parameter.

1 Like

it is a text parameter

imagem

:frowning:

Do you obtain the values with the Element.GetParameterValueByName node ?

yes

So it is a type parameter not a instance parameter :

import clr

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference(“RevitServices”)
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

elements = UnwrapElement(IN[0])
values = []

for element in elements:
    value = doc.GetElement(element.GetTypeId()).LookupParameter('Code').AsString()
    values.append(value)

OUT = values
1 Like

That works!

Thank you so much Alban!

:blush: :hugs: