通过conn.AllRefs;可以找到与之连接的连接器。

//连接器连接的连接器
[TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class cmdConnected : 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();
        while (csi.MoveNext())
        {
            Connector conn = csi.Current as Connector;
            if (conn.IsConnected == true)//是否有连接
            {
                ConnectorSet connectorSet = conn.AllRefs;//找到所有连接器连接的连接器
                ConnectorSetIterator csiChild = connectorSet.ForwardIterator();
                while (csiChild.MoveNext())
                {
                    Connector connected = csiChild.Current as Connector;
                    if (null != connected && connected.Owner.UniqueId != conn.Owner.UniqueId)
                    {
                        // look for physical connections 
                        if (connected.ConnectorType == ConnectorType.End ||
                            connected.ConnectorType == ConnectorType.Curve ||
                            connected.ConnectorType == ConnectorType.Physical)
                        {
                            //判断是不是管件
                            if (connected.Owner is FamilyInstance)
                            {
                                TaskDialog.Show("fitting", connected.Owner.Name);
                            }
                        }
                    }
                }
            }
        }         ts.Commit();         return Result.Succeeded;
    }
}

url:http://greatverve.cnblogs.com/p/revit-mep-api-AllRefs.html

最新文章

  1. 在阿里云中编译Linux4.5.0内核 - Ubuntu内核编译教程
  2. 操作系统核心原理-7.设备管理:I/O原理
  3. HTML5视频播放
  4. kill
  5. 前端技术Bootstrap的hello world
  6. Linux下基于HTTP协议带用户认证的GIT开发环境设置
  7. Android——四种AterDialog
  8. php 模拟斗地主发牌简单易懂
  9. 上海Uber优步司机奖励政策(2月1日~2月7日)
  10. Watch OS2.0开发概述
  11. struts2整合spring出现的Unable to instantiate Action异常
  12. visual studio插件 visual assistx
  13. PHP json_encode()函数使用
  14. Bootstrap Paginator分页插件
  15. css3部分属性兼容性别扭写法(因为很多我就叫他别扭了,希望全面早早支持css3吧)
  16. [转]Python的3种格式化字符串方法
  17. 前端笔记之HTML5&CSS3(下)2D/3D转换&animate动画
  18. php7 date函数警告去除
  19. CSS 图像左右对齐
  20. 修改sqlserver的数据库名、物理名称和逻辑文件名

热门文章

  1. Web安全测试-WebScarab
  2. Linux sleep命令
  3. 【API】遍历进程的几种方式
  4. ApiCloud利用NVTabBar模块快速搭建起APP的框架
  5. Tesseract-OCR 3.05 多过语言文字识别(运行程序+中英日韩语言包)
  6. 001_chrome工具详解
  7. 转:vue2.0 keep-alive最佳实践
  8. python随笔(一)
  9. MongoDB学习笔记-1
  10. Java编程的逻辑 (36) - 泛型 (中) - 解析通配符