您的位置:首页 > 编程语言

Revit2014 支持编程创建管道并且立即赋予系统类型名称

2013-11-25 15:21 323 查看
在Revit2013里面,当我们用NewPipe创建完成一个管道后,若这个管断是独立的没有与其它已经具有系统类型的管道或终端设备连接,这个管段的系统类型属性是没有定义的。通过编程也无法赋予系统类型。 这个问题已经办法我已经写过一个博文:http://blog.csdn.net/JoeXiongjin/article/details/8133749

在Revit 2014里面,Pipe类提供了Create()方法来创建管子, 其参数如下所示:

public static Pipe Create(
	Document document,
	ElementId systemTypeId,
	ElementId pipeTypeId,
	ElementId levelId,
	XYZ firstPoint,
	XYZ secondPoint
)


我们可以看到在参数中可以指定系统类型的Id,这样生成的管段就自动具有系统类型信息了,Revit自动为这个管子创建了一个管道系统PipingSystem对象。

下面是实例代码:

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

using  Autodesk.Revit .DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB.Plumbing;

using Autodesk.Revit .ApplicationServices;
using Autodesk.Revit.Attributes ;
using Autodesk.Revit.UI.Selection;

  [TransactionAttribute(TransactionMode.Manual)]
public class CreatePipe2014 : IExternalCommand
{
    public Result Execute(ExternalCommandData commandData, 
      ref string messages, ElementSet elements)
    {

      UIApplication app = commandData.Application;
      Document doc = app.ActiveUIDocument.Document;

      Transaction trans = new Transaction(doc);
      trans.Start("createPipe");

      FilteredElementCollector collector = new FilteredElementCollector(doc);
      collector.OfClass(typeof(PipeType));

      PipeType pt = collector.FirstElement() as PipeType;

      //ElementId id = new ElementId((int)PipeSystemType.DomesticColdWater);

      FilteredElementCollector col = new FilteredElementCollector(doc);
      col.OfClass(typeof(PipingSystemType));
      ElementId id = col.FirstElementId();

      Pipe p = Pipe.Create(doc, id,pt.Id, doc.ActiveView.GenLevel.Id, new XYZ(0, 0, 0), new XYZ(10, 0, 0));

      trans.Commit();
			

      return Result.Succeeded ;
    }
}

转载请复制以下信息:原文链接: http://blog.csdn.net/joexiongjin/article/details/16944941作者: 叶雄进2013.11.25
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐