import clr
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import System
from System.Collections.Generic import List
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = IN[0]
element = UnwrapElement(IN[1])
# First method
name = []
value = []
DB = element.GetParameters("Марка")
for i in DB:
name.append(i.Definition.Name)
value.append(i.AsValueString())
# Second method
# DB = element.get_Parameter(BuiltInParameter.ALL_MODEL_MARK)
# name = DB.Definition.Name
# value = DB.AsValueString()
OUT = name, value, DB
What storage type is the parameter Марка? Is it equivalent to Mark? If so, the storage type is Text (string) and if you query it with AsValueString() it will return null. Try with AsString() instead
Yes, it’s equivalent to Mark. Thank you Thomas! It works!
May be there is a simple way to find out what storage type of each parameter of the element?
I copied the code exactly and tried this solution (“AsString()”) however is not working for me.
I am trying to read the value of a shared parameter…maybe this is the reason why this doesnt work. You tried it with values of family parameters, didnt you?
What sort of storage type is your shared parameter? AsString() is only appropriate if your parameter is text (string). If it is numeric then AsInteger() or AsDouble() or AsValueString() would be what is needed. You can see the descriptions of these methods here: Parameter Methods
The original query was for the built-in parameter Mark which is stored as a string. But whether it is a built-in, family, project or shared parameter doesn’t make any difference to retrieiving the value.
import clr
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import System
from System.Collections.Generic import List
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
def tolist(obj1):
if hasattr(obj1,"__iter__"): return obj1
else: return [obj1]
def getParam(element,param):
value = []
try:
DB = element.GetParameters(param)
for i in DB:
if "Double" in str(i.StorageType):
# Metric Converstion
value.append(i.AsDouble()*304.8)
elif "Integer" in str(i.StorageType):
value.append(i.AsInteger())
elif "String" in str(i.StorageType):
value.append(i.AsString())
else:
elemId =i.AsElementId()
value.append(doc.GetElement(elemId))
except:
pass
return value
input = tolist(IN[0])
params = IN[1]
result = []
# Get parameters for Multiple Elements
for i in input:
pack = []
for p in params:
elem = UnwrapElement(i)
pack.append(getParam(elem,p))
result.append(pack)
OUT = result