//连接器
[TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class cmdConnector : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
{
UIApplication app = commandData.Application;
Document doc = app.ActiveUIDocument.Document;
Selection sel = app.ActiveUIDocument.Selection;
Transaction ts = new Transaction(doc, "revit");
ts.Start();
Reference refDuct = sel.PickObject(ObjectType.Element, "duct");
Duct duct = doc.GetElement(refDuct) as Duct;
ConnectorSetIterator csi = duct.ConnectorManager.Connectors.ForwardIterator();
int iCount = 0;
int iEnd = 0;
int iCurve = 0;
while (csi.MoveNext())
{
iCount += 1;
Connector conn = csi.Current as Connector;
if (ConnectorType.End == conn.ConnectorType)//一般风管的连接器
{
iEnd += 1;
}
else if (ConnectorType.Curve == conn.ConnectorType)//风管曲线上的连接器
{
iCurve += 1;
}
}
TaskDialog.Show("count", iCount + "," + iEnd + "," + iCurve + "," + duct.UniqueId);
ts.Commit();
return Result.Succeeded;
}
}
[TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class cmdConnector : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
{
UIApplication app = commandData.Application;
Document doc = app.ActiveUIDocument.Document;
Selection sel = app.ActiveUIDocument.Selection;
Transaction ts = new Transaction(doc, "revit");
ts.Start();
Reference refDuct = sel.PickObject(ObjectType.Element, "duct");
Duct duct = doc.GetElement(refDuct) as Duct;
ConnectorSetIterator csi = duct.ConnectorManager.Connectors.ForwardIterator();
int iCount = 0;
int iEnd = 0;
int iCurve = 0;
while (csi.MoveNext())
{
iCount += 1;
Connector conn = csi.Current as Connector;
if (ConnectorType.End == conn.ConnectorType)//一般风管的连接器
{
iEnd += 1;
}
else if (ConnectorType.Curve == conn.ConnectorType)//风管曲线上的连接器
{
iCurve += 1;
}
}
TaskDialog.Show("count", iCount + "," + iEnd + "," + iCurve + "," + duct.UniqueId);
ts.Commit();
return Result.Succeeded;
}
}