How to get value of instance shared text parameter in Python Script?


#1

“TextParameter” is some shared text parameter using for room instance.
How can i get its value in PythonScript node like this:

value = room.GetParameter('TextParameter')

GetParameter() not working (object has no attribute)
get_Parameter not working (object has no attribute)

It is about Revit 2016


#2

Hi @pvgdrk,

Are you trying to get parameter value using Python?

Can you elaborate more or highlight with some images.


#3

Try this solution:

import clr

clr.AddReference("RevitAPI")
clr.AddReference("RevitServices")

import Autodesk
import RevitServices

from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager

doc =  DocumentManager.Instance.CurrentDBDocument

collector = FilteredElementCollector(doc)
rooms = collector.OfCategory(BuiltInCategory.OST_Rooms).ToElements()

out = []
for room in rooms:
    for param in room.Parameters:
        if param.IsShared and param.Definition.Name == 'Parameter 1':
            paramValue = room.get_Parameter(param.GUID)
            out.append(paramValue.AsString())   
         
OUT = out


#4

Thanks! It is work. But is it possible to get access directly to object instance but not using loop for “room.Parameters”?
Some thing like value = roomInstance.getParamMethod('Parameter 1')


#5

value = room.LookupParameter(‘TextParameter’).AsString()