在Revit2013里面,当我们用NewPipe创建完成一个管道后,若这个管断是独立的没有与其它已经具有系统类型的管道或终端设备连接,这个管段的系统类型属性是没有定义的。通过编程也无法赋予系统类型。 这个问题已经办法我已经写过一个博文:http://blog.csdn.net/JoeXiongjin/article/details/8133749
在Revit 2014里面,Pipe类提供了Create()方法来创建管子, 其参数如下所示:public static Pipe Create( - <p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px; "></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px; "></p><pre xml:space="preserve" style="white-space: pre-wrap; color: rgb(51, 51, 51); line-height: 26px; "> <a target="_blank" href="http://blog.csdn.net/joexiongjin/article/details/16944941" style="text-decoration: none; ">Document</a> <span class="parameter">document</span>,
- <a target="_blank" href="http://blog.csdn.net/joexiongjin/article/details/16944941" style="text-decoration: none; ">ElementId</a> <span class="parameter">systemTypeId</span>,
- <a target="_blank" href="http://blog.csdn.net/joexiongjin/article/details/16944941" style="text-decoration: none; ">ElementId</a> <span class="parameter">pipeTypeId</span>,
- <a target="_blank" href="http://blog.csdn.net/joexiongjin/article/details/16944941" style="text-decoration: none; ">ElementId</a> <span class="parameter">levelId</span>,
- <a target="_blank" href="http://blog.csdn.net/joexiongjin/article/details/16944941" style="text-decoration: none; ">XYZ</a> <span class="parameter">firstPoint</span>,
- <a target="_blank" href="http://blog.csdn.net/joexiongjin/article/details/16944941" style="text-decoration: none; ">XYZ</a> <span class="parameter">secondPoint</span>
- )</pre>
复制代码我们可以看到在参数中可以指定系统类型的Id,这样生成的管段就自动具有系统类型信息了,Revit自动为这个管子创建了一个管道系统PipingSystem对象。
下面是实例代码:
[csharp] view plaincopy
- <li class="alt" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; "><span style="border: none; color: black; background-color: inherit; "><span class="keyword" style="border: none; color: rgb(0, 102, 153); background-color: inherit; font-weight: bold; ">using</span><span style="border: none; background-color: inherit; "> System; </span></span></li><li class="" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); "><span style="border: none; color: black; background-color: inherit; "><span class="keyword" style="border: none; color: rgb(0, 102, 153); background-color: inherit; font-weight: bold; ">using</span><span style="border: none; background-color: inherit; "> System.Collections.Generic; </span></span></li><li class="alt" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; "><span style="border: none; color: black; background-color: inherit; "><span class="keyword" style="border: none; color: rgb(0, 102, 153); background-color: inherit; font-weight: bold; ">using</span><span style="border: none; background-color: inherit; "> System.Text; </span></span></li><li class="" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); "><span style="border: none; color: black; background-color: inherit; "><span class="keyword" style="border: none; color: rgb(0, 102, 153); background-color: inherit; font-weight: bold; ">using</span><span style="border: none; background-color: inherit; "> System.Windows.Forms; </span></span></li><li class="alt" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; "><span style="border: none; color: black; background-color: inherit; "> </span></li><li class="" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); "><span style="border: none; color: black; background-color: inherit; "><span class="keyword" style="border: none; color: rgb(0, 102, 153); background-color: inherit; font-weight: bold; ">using</span><span style="border: none; background-color: inherit; "> Autodesk.Revit .DB; </span></span></li><li class="alt" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; "><span style="border: none; color: black; background-color: inherit; "><span class="keyword" style="border: none; color: rgb(0, 102, 153); background-color: inherit; font-weight: bold; ">using</span><span style="border: none; background-color: inherit; "> Autodesk.Revit.UI; </span></span></li><li class="" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); "><span style="border: none; color: black; background-color: inherit; "><span class="keyword" style="border: none; color: rgb(0, 102, 153); background-color: inherit; font-weight: bold; ">using</span><span style="border: none; background-color: inherit; "> Autodesk.Revit.DB.Plumbing; </span></span></li><li class="alt" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; "><span style="border: none; color: black; background-color: inherit; "> </span></li><li class="" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); "><span style="border: none; color: black; background-color: inherit; "><span class="keyword" style="border: none; color: rgb(0, 102, 153); background-color: inherit; font-weight: bold; ">using</span><span style="border: none; background-color: inherit; "> Autodesk.Revit .ApplicationServices; </span></span></li><li class="alt" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; "><span style="border: none; color: black; background-color: inherit; "><span class="keyword" style="border: none; color: rgb(0, 102, 153); background-color: inherit; font-weight: bold; ">using</span><span style="border: none; background-color: inherit; "> Autodesk.Revit.Attributes ; </span></span></li><li class="" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); "><span style="border: none; color: black; background-color: inherit; "><span class="keyword" style="border: none; color: rgb(0, 102, 153); background-color: inherit; font-weight: bold; ">using</span><span style="border: none; background-color: inherit; "> Autodesk.Revit.UI.Selection; </span></span></li><li class="alt" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; "><span style="border: none; color: black; background-color: inherit; "> </span></li><li class="" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); "><span style="border: none; color: black; background-color: inherit; "> </span></li><li class="alt" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; "><span style="border: none; color: black; background-color: inherit; "> [TransactionAttribute(TransactionMode.Manual)] </span></li><li class="" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); "><span style="border: none; color: black; background-color: inherit; "><span class="keyword" style="border: none; color: rgb(0, 102, 153); background-color: inherit; font-weight: bold; ">public</span><span style="border: none; background-color: inherit; "> </span><span class="keyword" style="border: none; color: rgb(0, 102, 153); background-color: inherit; font-weight: bold; ">class</span><span style="border: none; background-color: inherit; "> CreatePipe2014 : IExternalCommand </span></span></li><li class="alt" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; "><span style="border: none; color: black; background-color: inherit; ">{ </span></li><li class="" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); "><span style="border: none; color: black; background-color: inherit; "> <span class="keyword" style="border: none; color: rgb(0, 102, 153); background-color: inherit; font-weight: bold; ">public</span><span style="border: none; background-color: inherit; "> Result Execute(ExternalCommandData commandData, </span></span></li><li class="alt" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; "><span style="border: none; color: black; background-color: inherit; "> <span class="keyword" style="border: none; color: rgb(0, 102, 153); background-color: inherit; font-weight: bold; ">ref</span><span style="border: none; background-color: inherit; "> </span><span class="keyword" style="border: none; color: rgb(0, 102, 153); background-color: inherit; font-weight: bold; ">string</span><span style="border: none; background-color: inherit; "> messages, ElementSet elements) </span></span></li><li class="" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); "><span style="border: none; color: black; background-color: inherit; "> { </span></li><li class="alt" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; "><span style="border: none; color: black; background-color: inherit; "> </span></li><li class="" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); "><span style="border: none; color: black; background-color: inherit; "> UIApplication app = commandData.Application; </span></li><li class="alt" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; "><span style="border: none; color: black; background-color: inherit; "> Document doc = app.ActiveUIDocument.Document; </span></li><li class="" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); "><span style="border: none; color: black; background-color: inherit; "> </span></li><li class="alt" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; "><span style="border: none; color: black; background-color: inherit; "> </span></li><li class="" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); "><span style="border: none; color: black; background-color: inherit; "> Transaction trans = <span class="keyword" style="border: none; color: rgb(0, 102, 153); background-color: inherit; font-weight: bold; ">new</span><span style="border: none; background-color: inherit; "> Transaction(doc); </span></span></li><li class="alt" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; "><span style="border: none; color: black; background-color: inherit; "> trans.Start(<span class="string" style="border: none; color: blue; background-color: inherit; ">"createPipe"</span><span style="border: none; background-color: inherit; ">); </span></span></li><li class="" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); "><span style="border: none; color: black; background-color: inherit; "> </span></li><li class="alt" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; "><span style="border: none; color: black; background-color: inherit; "> FilteredElementCollector collector = <span class="keyword" style="border: none; color: rgb(0, 102, 153); background-color: inherit; font-weight: bold; ">new</span><span style="border: none; background-color: inherit; "> FilteredElementCollector(doc); </span></span></li><li class="" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); "><span style="border: none; color: black; background-color: inherit; "> collector.OfClass(<span class="keyword" style="border: none; color: rgb(0, 102, 153); background-color: inherit; font-weight: bold; ">typeof</span><span style="border: none; background-color: inherit; ">(PipeType)); </span></span></li><li class="alt" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; "><span style="border: none; color: black; background-color: inherit; "> </span></li><li class="" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); "><span style="border: none; color: black; background-color: inherit; "> PipeType pt = collector.FirstElement() <span class="keyword" style="border: none; color: rgb(0, 102, 153); background-color: inherit; font-weight: bold; ">as</span><span style="border: none; background-color: inherit; "> PipeType; </span></span></li><li class="alt" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; "><span style="border: none; color: black; background-color: inherit; "> </span></li><li class="" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); "><span style="border: none; color: black; background-color: inherit; "> <span class="comment" style="border: none; color: rgb(0, 130, 0); background-color: inherit; ">//ElementId id = new ElementId((int)PipeSystemType.DomesticColdWater);</span><span style="border: none; background-color: inherit; "> </span></span></li><li class="alt" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; "><span style="border: none; color: black; background-color: inherit; "> </span></li><li class="" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); "><span style="border: none; color: black; background-color: inherit; "> FilteredElementCollector col = <span class="keyword" style="border: none; color: rgb(0, 102, 153); background-color: inherit; font-weight: bold; ">new</span><span style="border: none; background-color: inherit; "> FilteredElementCollector(doc); </span></span></li><li class="alt" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; "><span style="border: none; color: black; background-color: inherit; "> col.OfClass(<span class="keyword" style="border: none; color: rgb(0, 102, 153); background-color: inherit; font-weight: bold; ">typeof</span><span style="border: none; background-color: inherit; ">(PipingSystemType)); </span></span></li><li class="" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); "><span style="border: none; color: black; background-color: inherit; "> ElementId id = col.FirstElementId(); </span></li><li class="alt" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; "><span style="border: none; color: black; background-color: inherit; "> </span></li><li class="" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); "><span style="border: none; color: black; background-color: inherit; "> </span></li><li class="alt" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; "><span style="border: none; color: black; background-color: inherit; "> Pipe p = Pipe.Create(doc, id,pt.Id, doc.ActiveView.GenLevel.Id, <span class="keyword" style="border: none; color: rgb(0, 102, 153); background-color: inherit; font-weight: bold; ">new</span><span style="border: none; background-color: inherit; "> XYZ(0, 0, 0), </span><span class="keyword" style="border: none; color: rgb(0, 102, 153); background-color: inherit; font-weight: bold; ">new</span><span style="border: none; background-color: inherit; "> XYZ(10, 0, 0)); </span></span></li><li class="" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); "><span style="border: none; color: black; background-color: inherit; "> </span></li><li class="alt" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; "><span style="border: none; color: black; background-color: inherit; "> trans.Commit(); </span></li><li class="" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); "><span style="border: none; color: black; background-color: inherit; "> </span></li><li class="alt" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; "><span style="border: none; color: black; background-color: inherit; "> </span></li><li class="" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); "><span style="border: none; color: black; background-color: inherit; "> <span class="keyword" style="border: none; color: rgb(0, 102, 153); background-color: inherit; font-weight: bold; ">return</span><span style="border: none; background-color: inherit; "> Result.Succeeded ; </span></span></li><li class="alt" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; color: inherit; "><span style="border: none; color: black; background-color: inherit; "> } </span></li><li class="" style="margin-left: 0px !important; padding-right: 3px !important; padding-left: 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); "><span style="border: none; color: black; background-color: inherit; ">} </span></li>
复制代码
原文链接: http://blog.csdn.net/joexiongjin/article/details/16944941 作者: 叶雄进
|