在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