123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- using Autodesk.Revit.DB;
- using Autodesk.Revit.DB.Mechanical;
- using Autodesk.Revit.DB.Plumbing;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace FWindSoft.Revit
- {
- public static class MepSystemTypeExtension
- {
- public static readonly ReadOnlyCollection<string> DuctClassifications =new ReadOnlyCollection<string>( new List<string> { "SupplyAir", "ReturnAir", "ExhaustAir" });
- public static readonly ReadOnlyCollection<string> PipeClassifications = new ReadOnlyCollection<string>(new List<string> { "Sanitary",
- "Vent",
- "DomesticHotWater",
- "DomesticColdWater",
- "OtherPipe",
- "FireProtectWet",
- "FireProtectDry",
- "FireProtectPreaction",
- "FireProtectOther",
- "SupplyHydronic",
- "ReturnHydronic"});
- /// <summary>
- /// 根据系统分类创建系统类型
- /// </summary>
- /// <param name="doc">创建系统的指定项目</param>
- /// <param name="classification">系统分类</param>
- /// <param name="name">系统名称</param>
- /// <returns></returns>
- public static MEPSystemType MEPSystemTypeCreate(this Document doc, MEPSystemClassification classification,string name)
- {
-
- if (DuctClassifications.Contains(classification.ToString()))
- return MechanicalSystemType.Create(doc, classification, name);
- if (PipeClassifications.Contains(classification.ToString()))
- return PipingSystemType.Create(doc, classification, name);
- return null;
- }
- /// <summary>
- /// 或取全部管道系统(可指定相应的系统分类)
- /// </summary>
- /// <param name="doc"></param>
- /// <param name="classification"></param>
- /// <returns></returns>
- public static List<PipingSystemType> GetPipingSystemTypes(this Document doc,
- MEPSystemClassification classification = MEPSystemClassification.UndefinedSystemClassification)
- {
- ElementCategoryFilter pipeSystemFilter = new ElementCategoryFilter(BuiltInCategory.OST_PipingSystem);
- List<PipingSystemType> list = doc.GetElements<PipingSystemType>();
- if (classification != MEPSystemClassification.UndefinedSystemClassification)
- {
- list = list.Where(s => s.SystemClassification == classification).ToList();
- }
- return list;
- }
- /// <summary>
- /// 或取项目已经使用的管道系统(可指定相应的系统分类)
- /// </summary>
- /// <param name="doc"></param>
- /// <param name="classification"></param>
- /// <returns></returns>
- public static List<PipingSystemType> GetUsedPipingSystemTypes(this Document doc,
- MEPSystemClassification classification = MEPSystemClassification.UndefinedSystemClassification)
- {
- ElementCategoryFilter pipeSystemFilter = new ElementCategoryFilter(BuiltInCategory.OST_PipingSystem);
- var listIds = doc.GetElements<PipingSystem>().Select(p => p.GetTypeId()).Distinct();
- List<Element> list = listIds.Select(id => doc.GetElement(id)).ToList();
- List<PipingSystemType> tempSystemType = list.OfType<PipingSystemType>().ToList();
- if (classification != MEPSystemClassification.UndefinedSystemClassification)
- {
- tempSystemType = tempSystemType.Where(s => s.SystemClassification == classification).ToList();
- }
- return tempSystemType;
- }
- /// <summary>
- /// 或取全部风管系统类型(可指定相应的系统分类)
- /// </summary>
- /// <param name="doc"></param>
- /// <param name="classification"></param>
- /// <returns></returns>
- public static List<MechanicalSystemType> GetMechanicalSystemTypes(this Document doc,
- MEPSystemClassification classification = MEPSystemClassification.UndefinedSystemClassification)
- {
- ElementCategoryFilter ductSystemFilter = new ElementCategoryFilter(BuiltInCategory.OST_DuctSystem);
- List<MechanicalSystemType> list = doc.GetElements(ductSystemFilter).OfType<MechanicalSystemType>().ToList();
- if (classification != MEPSystemClassification.UndefinedSystemClassification)
- {
- list = list.Where(s => s.SystemClassification == classification).ToList();
- }
- return list;
- }
- /// <summary>
- /// 或取项目已经使用的风管系统系统(可指定相应的系统分类)
- /// </summary>
- /// <param name="doc"></param>
- /// <param name="classification"></param>
- /// <returns></returns>
- public static List<MechanicalSystemType> GetUsedMechanicalSystemTypes(this Document doc,
- MEPSystemClassification classification = MEPSystemClassification.UndefinedSystemClassification)
- {
- ElementCategoryFilter ductSystemFilter = new ElementCategoryFilter(BuiltInCategory.OST_DuctSystem);
- var listIds = doc.GetElements(ductSystemFilter).OfType<MechanicalSystemType>()
- .Select(p => p.GetTypeId())
- .Distinct();
- List<Element> list = listIds.Select(id => doc.GetElement(id)).ToList();
- List<MechanicalSystemType> tempSystemType = list.OfType<MechanicalSystemType>().ToList();
- if (classification != MEPSystemClassification.UndefinedSystemClassification)
- {
- tempSystemType = tempSystemType.Where(s => s.SystemClassification == classification).ToList();
- }
- return tempSystemType;
- }
- }
- }
|