RevitAPI之創建風管

創建一般風管可以調用RevitAPI的函數Duct.Create:
Duct Create(Document document,Elementld systemTypeld,Elementld ductTypeld, 
Elementld levelld, XYZ firstPoint, XYZ secondPoint) 

參數含義見下表。

參數

描述

Document

文檔

systemTypeld

水暖電系統族的Id

ductTypeld

風管類型的Id

levelld

所在標高的Id

firstPoint

起點

secondPoint

終點


如果要創建風管,可以根據MEPSystemClassification 過濾出風管類型參數,然後使用Duct.Create創建。


代碼如下:
public Duct CreateDuct(Document doc, ElementId levelId, MEPSystemClassification ductSystemType, ElementId ductTypeId, XYZ startPoint, XYZ endPoint)
        {
            ElementId systemTypeId = ElementId.InvalidElementId;

            // 獲取類型爲SupplyAir的系統類型 
            var systemTypeFilter = new ElementClassFilter(typeof(MEPSystemType));
            FilteredElementCollector systemTypes = new FilteredElementCollector(doc);
            systemTypes = systemTypes.WherePasses(systemTypeFilter);
            List<MEPSystemType> systypes = new List<MEPSystemType>();
            foreach (MEPSystemType element in systemTypes)
            {
                if (element.SystemClassification == ductSystemType)
                {
                    systemTypeId = element.Id;
                    break;
                }
            }
            if (systemTypeId == ElementId.InvalidElementId)
                throw new Exception("無法找到系統類型");

            // 創建風管 
            using (Transaction transaction = new Transaction(doc))
            {
                transaction.Start("創建風管");
                Duct duct = Duct.Create(doc, systemTypeId, ductTypeId, levelId, startPoint, endPoint);
                transaction.Commit();
                return duct;
            }
        }

=========【更多高級應用請關注公衆號】========


==================================



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章