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


在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


  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值