zoukankan      html  css  js  c++  java
  • 建筑墙体信息获取(材质名称,材质,面积,体积,厚度)

    分别得到:材质名称,材质,面积,体积,厚度

    import clr
    clr.AddReference("RevitNodes")
    import Revit
    clr.ImportExtensions(Revit.Elements)
    
    clr.AddReference("DSCoreNodes")
    import DSCore
    from DSCore import *
    clr.AddReference("RevitServices")
    import RevitServices
    from RevitServices.Persistence import DocumentManager
    
    clr.AddReference("RevitAPI")
    import Autodesk
    from Autodesk.Revit.DB import *
    
    import System
    from System.Collections.Generic import *
    
    doc = DocumentManager.Instance.CurrentDBDocument
    walls = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType().ToElements()
    
    elementmats = list()
    elementareas = list()
    elementvols = list()
    elementnames = list()
    elementthicks = list()
    elementnames_temp = list()
    elementthicks_temp = list()
    paintedmats=False
    for wall in walls:
    
        matlist = list()
        arealist = list()
        vollist = list()
        namelist = list()
        namelist_temp = list()
        thicklist_temp = list()
        thicklist = list()
        for matid in wall.GetMaterialIds(paintedmats):
    
            matlist.append(wall.Document.GetElement(matid))
            arealist.append(wall.GetMaterialArea(matid,paintedmats))
            vollist.append(wall.GetMaterialVolume(matid))
            ele=doc.GetElement(matid)
            namelist.append(ele.Name)
    
    
        layers=wall.WallType.GetCompoundStructure().GetLayers()
        for layer in layers:
            thicklist_temp.append(layer.Width * 304.8)
            ele = doc.GetElement(layer.MaterialId)
            namelist_temp.append(ele.Name)
        elementnames_temp.append(namelist_temp)
        elementthicks_temp.append(thicklist)
        elementmats.append(matlist)
        elementareas.append(arealist)
        elementvols.append(vollist)
        elementnames.append(namelist)
    
        for each in namelist_temp:
            thicklist.append(thicklist_temp[namelist.index(each)])
        elementthicks.append(thicklist)
    
    def flatten_list(a,result=None):
        if result is None:
            result=[]
        for x in a:
            if isinstance(x,list):
                flatten_list(x,result)
            else:
                result.append(x)
        return result
    
    elementnames_e=flatten_list(elementnames)
    elementmats_e=flatten_list(elementmats)
    elementareas_e=flatten_list(elementareas)
    elementvols_e=flatten_list(elementvols)
    elementthicks_e=flatten_list(elementthicks)
    b=set(elementnames_e)
    OUT=(elementnames_e,elementmats_e,elementareas_e,elementvols_e,elementthicks_e)
    '''def Quchong(a):
        b=[]
        for each in a:
            if each not in b:
                b.append(each)'''
  • 相关阅读:
    0--分析JDK及其他开源框架的初衷
    2.2--RandomAccessFile实现类和它的关联类FileChannel
    2.1--RandomAccessFile实现类的关联类FileChannel类图
    2--IO包DataInput接口类图
    1--UML语言IO包组件图
    跟老齐学Python Django实战 5/n Second edition
    跟老齐学Python Django实战 3/n Second edition
    Vim
    跟老齐学Python Django实战 2/n Second edition
    跟老齐学Python Django实战 1/n Second edition
  • 原文地址:https://www.cnblogs.com/ShirleyX/p/8310804.html
Copyright © 2011-2022 走看看