Revit中元素重要的屬性和方法

Category(類別),Location(位置),LevelId(標高), GroupId(組),Id,UniqueId(唯一Id)等都是元素的幾個重要屬性。
重要的方法:GetMaterials(),Get AnalyticalModel()

1) 位置Location
Element.Location屬性用來獲取元素的位置,Location可以轉型爲LocationPoint和 LocationCurve,如果該元素的位置是點,則轉型爲LocationPoint,如果是直線或者曲線,則使用LocationCurve。類圖見圖3-9。

2) 材質Material
GetMaterials(bool)函數可以獲取元素的材質, bool爲true的時候,獲取的是元素的油漆材質 (Painted Material)
3) 分析模型
分析模型主要被用來做結構分析,獲取分析模型可以使用Element.GetAnalyticalModel()方法,然後調用分析模型的GetCurve,GetCurves或GetPoint來獲取分析模型的幾何信息。同時可通過IsSingleCurve()和IsSinglePoint()方法來輔助判斷需要調用哪個方法。

//============代碼片段3-11 獲取分析模型的幾何信息============ 
        public void GetAnalyticalModel(Document RevitDoc)
        {
            Element element = RevitDoc.GetElement(new ElementId(183554));
            if (element == null) return;
            AnalyticalModel analyticalModel = element.GetAnalyticalModel();
            if (analyticalModel.IsSingleCurve())
            {
                Curve curve = analyticalModel.GetCurve();
                // work with curve 
            }
            else if (analyticalModel.IsSinglePoint())
            {
                XYZ p = analyticalModel.GetPoint();
                // work with point 
            }
            else
            {
                IList<Curve> curves = analyticalModel.GetCurves(AnalyticalCurveType.ActiveCurves);
                // work with curves 
            }
        }

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


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



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