Revit二次开发--创建管道

Pipe.Create()方法,而这个方法有3种重载
Create(Document, ElementId, ElementId, Connector, Connector)
Create(Document, ElementId, ElementId, Connector, XYZ)
Create(Document, ElementId, ElementId, ElementId, XYZ, XYZ)

参数分析:
前两种方法中:
第一个ElementId 代表管道类型,可以通过过滤器,过滤PipeType类型得到
第二个ElementId 代表管道所在标高,可以通过过滤器,过滤Level取得,
后面两个参数是用来设置管道的两个端点的,也可以是管道的连接头;

对于第三个重载方法中
第一个ElementId 代表管道系统类型,可以通过过滤器过滤ipingSystemType取得
第一个ElementId 代表管道类型
第二个ElementId 代表管道所在标高

下面是使用第三种重载方法创建的一条立管:

	 public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
    {
        UIDocument uiDoc = commandData.Application.ActiveUIDocument;
        Document doc = uiDoc.Document;

        using (Transaction trans = new Transaction(doc))
        {
            trans.Start("Create Pipe");
            FilteredElementCollector pipeSystem = new FilteredElementCollector(doc);
            pipeSystem.OfClass(typeof(PipingSystemType));
            PipingSystemType  pipesystemType = pipeSystem.ToList().First() as PipingSystemType;

            FilteredElementCollector pipetype = new FilteredElementCollector(doc);
            pipetype.OfClass(typeof(PipeType));
            PipeType type = pipetype.ToList().First() as PipeType;

            Pipe pipe = Pipe.Create(doc,pipesystemType.Id,type.Id,Level.Create(doc,5).Id,new XYZ(),new XYZ(0,0,50));

            trans.Commit();
        }
        return Result.Succeeded;
    }

猜你喜欢

转载自blog.csdn.net/qq_43026206/article/details/85342002
今日推荐