Revit API电缆桥架CableTray

电缆桥架CableTray与风管一样是曲线几何。
using Autodesk.Revit.DB.Electrical;

namespace RevitCodes
{
    [Transaction(TransactionMode.Manual)]
    [Regeneration(RegenerationOption.Manual)]
    public class cmdTest20110905 : IExternalCommand
    {
        public Result Execute(ExternalCommandData cmdData, ref string messages, ElementSet elements)
        {
            UIDocument uiDoc = cmdData.Application.ActiveUIDocument;
            //电缆桥架
            
//BuiltInCategory.OST_CableTray;
            Transaction ts = new Transaction(uiDoc.Document, "电缆桥架");
            ts.Start();
            Reference refCable = uiDoc.Selection.PickObject(ObjectType.Element, "选择一个桥架");
            CableTray cableTray = uiDoc.Document.GetElement(refCable) as CableTray;
            LocationCurve lCurve = cableTray.Location as LocationCurve;
            if (lCurve != null)
            {
                TaskDialog.Show("curve", lCurve.Curve.Length.ToString());
            }

            ts.Commit();
            return Result.Succeeded;
        }
    }
}
from:http://revit.5d6d.com/thread-1329-1-2.html
posted @ 2011-11-18 10:49  大气象  阅读(2092)  评论(1编辑  收藏  举报
http://www.tianqiweiqi.com