电缆桥架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; } } }