【问题标题】:Is there an function for writing all Elements and Characteristics from Revit in an .csv file?是否有将 Revit 中的所有元素和特征写入 .csv 文件的功能?
【发布时间】:2020-10-06 00:03:17
【问题描述】:

我使用 Revit(PyRevit) 并希望将所有使用过的元素及其特征写入 .csv 文件中。

这是一个例子:

Get Parameter Value by Name 
Get value of one of element's parameters.

TESTED REVIT API: 2016,2017

Author: Francisco Possetto | github.com/franpossetto

Shared on www.revitapidocs.com
For more information visit http://github.com/gtalarico/revitapidocs
License: http://github.com/gtalarico/revitapidocs/blob/master/LICENSE.md
"""

#Imports.
from Autodesk.Revit.DB import Element

doc = __revit__.ActiveUIDocument.Document
uidoc = __revit__.ActiveUIDocument

def get_parameter_value_by_name(element, parameterName):
    return element.LookupParameter(parameterName).AsValueString()

#Select elements from revit.
selection = [doc.GetElement(x) for x in uidoc.Selection.GetElementIds()]

#Example with Walls.
for wall in selection:
    print get_parameter_value_by_name(wall, "Base Constraint")

但是我只得到“基本约束”是否可以将所有元素/类别放入该文件中?

非常感谢。最好的问候

【问题讨论】:

    标签: python autodesk revit pyrevit write


    【解决方案1】:

    您可以使用 rpw Collector 获取所有 FamilySymbol 元素。如果您只想要项目中的所有实例。只需使用 'FamilyInstance' 来获取它们。

    from rpw import db
    
    collector = db.Collector(of_class='FamilySymbol')
    elements = collector.get_elements()
    
    for e in elements:
        print(e.name)
    

    【讨论】:

      猜你喜欢
      • 2019-11-30
      • 2011-12-10
      • 1970-01-01
      • 1970-01-01
      • 2011-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多