zoukankan      html  css  js  c++  java
  • Revit MEP API找到连接器连接的连接器

    通过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
  • 相关阅读:
    COCI 2018/2019 CONTEST #2 Solution
    点分治学习笔记
    【Treap 例题】神秘岛(island)
    【暴力Treap 或 离线归并】子串计数(genies)
    【拓扑 字符串还原 + 线段树维护】奇洛金卡达(father)
    UVA 10217 A Dinner with Schwarzenegger!!!---数学
    URAL-1018 Binary Apple Tree---树形DP
    ZOJ-3278 8G Island---二分第k大
    UVA-1152-4 Values whose Sum is 0---中途相遇法
    SGU---462 Electrician 最大生成树
  • 原文地址:https://www.cnblogs.com/greatverve/p/revit-mep-api-AllRefs.html
Copyright © 2011-2022 走看看