Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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
Comment

PREVIOUS NEXT
Code Example
Python :: numpy substract subsequent elements 
Python :: how to play mp3 file form pygame module 
Python :: Fernet: Cannot decrypt strings saved in csv with pandas 
Python :: function continuity python 
Python :: timeplanner-1 
Python :: python check if more than 1 is true 
Python :: torch.unsqueze 
Python :: pandas plot column titles vertical 
Python :: is python the best robotic langauge 
Python :: online python compailer 
Python :: Cget subassembly civid3d 
Python :: how ti maek a prinyt comnad i pyuthon 
Python :: tkinter sin 
Python :: pybind11 python37_d.dll access violation 
Python :: get maximum values in a column by a subgroup of a dataframe pandas 
Python :: torch.unsqueeze 
Python :: check if a string is a palindrome python 
Python :: Walrus operator in list comprehensions [Python 3.8.0] 
Python :: total keywords in python 
Python :: powershell not printing until ctrl c 
Python :: check is symmetric python 
Python :: fetch api python 
Python :: how to open any application in python 
Python :: rotate list python 
Python :: mute command discord.py 
Python :: how to create a window in pygame 
Python :: python interpreter 
Python :: add an index column in range dataframe 
Python :: matplotlib set colorbar range 
Python :: games made with python 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =