分别得到:材质名称,材质,面积,体积,厚度
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)'''