revit 二次开发 模型线读取

目前只能读取模型线长度,闭合的区域读不到面积

UIApplication uiapp = commandData.Application;
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Document doc = uidoc.Document;

            //获取选取的模型线集合
            IList rList = uidoc.Selection.PickObjects(Autodesk.Revit.UI.Selection.ObjectType.Element);
            //遍历集合获取长度
            Double cLengths = 0;
            Double clengthss = 0;
            foreach (Reference r in rList)
            {
                ModelCurve mcurve = doc.GetElement(r) as ModelCurve;//获取模型线
                Curve geoCurve = mcurve.GeometryCurve;//获取模型线属性信息
                Double clength = geoCurve.Length;//获取模型线长度
                double cl = UnitUtils.Convert(clength, DisplayUnitType.DUT_DECIMAL_FEET, DisplayUnitType.DUT_MILLIMETERS);//英尺转换为毫米
                double cL = UnitUtils.Convert(clength, DisplayUnitType.DUT_DECIMAL_FEET, DisplayUnitType.DUT_METERS);//英尺转米
                cLengths += cl;
                clengthss += cL;
            }
            TaskDialog.Show("所点击模型线长度", "长度为:" + cLengths.ToString() + "mm" + "\r" + clengthss.ToString() + "m");

            return Result.Succeeded;

 

你可能感兴趣的:(revit 二次开发 模型线读取)