博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Revit MEP API找到连接器连接的连接器
阅读量:7023 次
发布时间:2019-06-28

本文共 1395 字,大约阅读时间需要 4 分钟。

通过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://onsxl.baihongyu.com/

你可能感兴趣的文章
fatal error C1853: '<filename>' is not a precompiled header file
查看>>
STUN和TURN技术浅析
查看>>
连接第二个 insance 到 first_local_net - 每天5分钟玩转 OpenStack(83)
查看>>
js scheme 打开手机app的方法
查看>>
【Hadoop】HADOOP 总结--思维导图
查看>>
java读写锁实现数据同步访问
查看>>
原生的社交分享
查看>>
delphi IOS 获取电池信息
查看>>
Unity3D 避免玩家作弊
查看>>
springMVC-数据的格式化
查看>>
JavaWeb学习笔记——JDOM
查看>>
bootstrap编码规范
查看>>
mongodb 简单部署方案及实例
查看>>
Adobe推出HTML5动画设计工具Edge
查看>>
检查使用共享表空间的表
查看>>
ArcGIS Server的切图原理深入【转】
查看>>
recyclerView插入(add)和删除(remove)item后,item错乱,重复,覆盖在原recyclerView上
查看>>
关于ftpshell脚本中mget中去除多余交互式提示的方法
查看>>
移动平台自动化测试从零开始-MonkeyRunner工具使用 (第二节)
查看>>
【320】Python 2.x 与 3.x 的区别
查看>>