• 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
  • 相关阅读:
    JQuery Ajax调用asp.net后台方法
    擦亮自己的眼睛去看SQLServer之简单Insert
    擦亮自己的眼睛去看SQLServer之简单Select
    SQL Server CONVERT() 函数
    给reporting services加个条件型的格式 (轉)
    优化SQL语句:in 和not in的替代方案
    技术不如你,但老板就是赏识他,为什么?
    LINQ to SQL活学活用(1):这要打破旧观念(轉)
    [续] MATLAB 混合编程——下篇:调用其它编程语言
    [精] MATLAB 混合编程——上篇:被其它编程语言调用
  • 原文地址:https://www.cnblogs.com/greatverve/p/revit-mep-api-AllRefs.html
Copyright © 2020-2023  润新知