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