📌  相关文章
📜  获取参数值dynamo python代码示例

📅  最后修改于: 2022-03-11 14:47:14.752000             🧑  作者: Mango

代码示例1
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