連接器的類別,風管不僅有兩端,可能在曲線上也有。
[TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)]
cmdConnector : IExternalCommand
{
Result Execute(ExternalCommandData commandData, messages, ElementSet elements)
{
UIApplication app = commandData.Application;
Document doc = app.ActiveUIDocument.Document;
Selection sel = app.ActiveUIDocument.Selection;
Transaction ts = Transaction(doc, );
ts.Start();
Reference refDuct = sel.PickObject(ObjectType.Element, );
Duct duct = doc.GetElement(refDuct) Duct;
ConnectorSetIterator csi = duct.ConnectorManager.Connectors.ForwardIterator();
iCount = ;
iEnd = ;
iCurve = ;
(csi.MoveNext())
{
iCount += ;
Connector conn = csi.Current Connector;
(ConnectorType.End == conn.ConnectorType) {
iEnd += ;
}
(ConnectorType.Curve == conn.ConnectorType) {
iCurve += ;
}
}
TaskDialog.Show(, iCount + + iEnd + + iCurve + + duct.UniqueId);
ts.Commit();
Result.Succeeded;
}
}url:http://greatverve.cnblogs.com/p/revit-mep-api-ConnectorType.html