Horje
get parameter value dynamo python Code Example
get parameter value dynamo python
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




Python

Related
free function in python Code Example free function in python Code Example
python detect ranges in list Code Example python detect ranges in list Code Example
flask socketio with gevent Code Example flask socketio with gevent Code Example
torch.nan_to_num Code Example torch.nan_to_num Code Example
how to read comment before the root element of xml python Code Example how to read comment before the root element of xml python Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8