EaBIM一直以来积极响应国家“十二五”推进建筑业信息化的号召,对建筑领域的信息技术开展深入技术交流和探讨!致力于打造“BIM-建筑师-生态技术”三位一体综合资源交流共享平台,希望为BIM与可持续设计理念及技术的普及做出微小的贡献!!!

EaBIM

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

搜索
查看: 518|回复: 1
打印 上一主题 下一主题

通过连接器找到所属元素

[复制链接]

1514

主题

7465

帖子

1万

积分

admin

Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10

积分
12396

社区QQ达人

跳转到指定楼层
楼主
发表于 2014-1-9 12:56:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

通过连接器找到所属元素。[Transaction(TransactionMode.Automatic)]
  1. <div align="left"></div><div align="left">[Regeneration(RegenerationOption.Automatic)]
  2. public class GetElementByConnector : IExternalCommand
  3. {
  4.     public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
  5.     {
  6.         UIApplication uiApp = commandData.Application;
  7.         Document doc = uiApp.ActiveUIDocument.Document;
  8.         Selection sel = uiApp.ActiveUIDocument.Selection;

  9.         Reference refelem = sel.PickObject(ObjectType.Element, "请选择一个风管");
  10.         Duct duct = refelem.Element as Duct;//这里也可以是风道末端之类MEPSystem

  11.         ConnectorSetIterator csi = duct.ConnectorManager.Connectors.ForwardIterator();
  12.         Connector conn = null;
  13.         while (csi.MoveNext())
  14.         {
  15.             conn = csi.Current as Connector;
  16.         }
  17.         GetElementAtConnector(conn);

  18.         return Result.Succeeded;
  19.     }
  20.     public void GetElementAtConnector(Connector connector)
  21.     {
  22.         MEPSystem mepSystem = connector.MEPSystem;
  23.         //if (null != mepSystem)//加上这个判断风管不属于
  24.         if (true)
  25.         {
  26.             string message = "Connector is owned by:" + connector.Owner.Name;
  27.             if (connector.IsConnected == true)//是否连接其他,比如弯头
  28.             {
  29.                 ConnectorSet connectorSet = connector.AllRefs;
  30.                 ConnectorSetIterator csi = connectorSet.ForwardIterator();
  31.                 while (csi.MoveNext())
  32.                 {
  33.                     Connector connected = csi.Current as Connector;
  34.                     if (null != connected)
  35.                     {
  36.                         if (connected.ConnectorType == ConnectorType.EndConn ||
  37.                             connected.ConnectorType == ConnectorType.CurveConn ||
  38.                             connected.ConnectorType == ConnectorType.PhysicalConn)
  39.                         {
  40.                             message += "\nConnecotr is connected to:" + connected.Owner.Name;
  41.                             message += "\nConnection type is:" + connected.ConnectorType;
  42.                         }
  43.                     }
  44.                 }
  45.             }
  46.             else
  47.             {
  48.                 message += "\nConnector is not connected to anything.";
  49.             }
  50.             MessageBox.Show(message, "Revit");
  51.         }
  52.     }
  53. }
  54. </div>
复制代码

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
收藏收藏 转播转播 分享分享 分享淘帖 支持支持 反对反对
工作时间:工作日的9:00-12:00/13:30-18:00,节假日不在线,请勿留言

2

主题

897

帖子

1365

积分

BIM经理

Rank: 6Rank: 6Rank: 6Rank: 6Rank: 6Rank: 6

积分
1365
2F
发表于 2014-2-20 14:39:05 | 只看该作者
(*^__^*) 嘻嘻……
*滑块验证:
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|EaBIM网 ( 苏ICP备2020058923号-1  苏公网安备32011502011255号

GMT+8, 2024-9-29 14:27

Powered by Discuz! X3.2 Licensed

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表