新しいダクト、フレキシブル ダクト、配管、フレキシブル配管の作成には 3 つの方法があります。2 つの点、2 つの接続、点と接続の間に作成できます。さらに、2 つの点の間にこれらのタイプの MEPCurves のいずれかを作成する場合は、対応するクラスの静的 Create()メソッドを使用できます。
次のコードは、Autodesk.Revit.Creation.Document.NewPipe()メソッドを使用して、2 つの点の間に新しい配管を作成します。新しいフレキシブル配管、ダクト、フレキシブル ダクトはすべて同様の方法で作成できます。
コード領域: NewPipe()メソッドを使用して新しい配管を作成 |
public Pipe CreateNewPipe(Document document) { // find a pipe type FilteredElementCollector collector = new FilteredElementCollector(document); collector.OfClass(typeof(PipeType)); PipeType pipeType = collector.FirstElement() as PipeType; Pipe pipe = null; if (null != pipeType) { // create pipe between 2 points XYZ p1 = new XYZ(0, 0, 0); XYZ p2 = new XYZ(10, 0, 0); pipe = document.Create.NewPipe(p1, p2, pipeType); } return pipe; } |
コード領域: 静的 Create()メソッドを使用して新しい FlexPipe を作成 |
public FlexPipe CreateFlexPipe(Document document, Level level) { // find a pipe type FilteredElementCollector collector = new FilteredElementCollector(document); collector.OfClass(typeof(FlexPipeType)); ElementId pipeTypeId = collector.FirstElementId(); // find a pipe system type FilteredElementCollector sysCollector = new FilteredElementCollector(document); sysCollector.OfClass(typeof(PipingSystemType)); ElementId pipeSysTypeId = sysCollector.FirstElementId(); FlexPipe pipe = null; if (pipeTypeId != ElementId.InvalidElementId && pipeSysTypeId != ElementId.InvalidElementId) { // create flex pipe with 3 points List<XYZ> points = new List<XYZ>(); points.Add(new XYZ(0, 0, 0)); points.Add(new XYZ(10, 10, 0)); points.Add(new XYZ(10, 0, 0)); pipe = FlexPipe.Create(document, pipeSysTypeId, pipeTypeId, level.Id, points); } return pipe; } |
配管を作成した後、直径を変更できます。配管の直径プロパティは読み込み専用です。直径を変更するには、RBS_PIPE_DIAMETER_PARAM 組み込みパラメータを取得します。
コード領域: パイプの直径を変更 |
public void ChangePipeSize(Pipe pipe) { Parameter parameter = pipe.get_Parameter(BuiltInParameter.RBS_PIPE_DIAMETER_PARAM); string message = "Pipe diameter: " + parameter.AsValueString(); parameter.Set(0.5); // set to 6" message += "\nPipe diameter after set: " + parameter.AsValueString(); MessageBox.Show(message, "Revit"); } |
その他に、次の例で示すように、2 つの既存の接続の間に新しいダクトや配管を作成する方法もよく使用されます。この例では、接続を持つ 2 つの要素がRevit MEP で選択されていると仮定します。1 つは機械設備で、もう 1 つは機器の SupplyAir 接続の位置に合う接続を持つダクト継手です。
コード領域: 2 つの接続間にダクトを追加 |
public Duct CreateDuctBetweenConnectors(UIDocument uiDocument) { // prior to running this example // select some mechanical equipment with a supply air connector // and an elbow duct fitting with a connector in line with that connector Connector connector1 = null, connector2 = null; ConnectorSetIterator csi = null; ICollection<ElementId> selectedIds = uiDocument.Selection.GetElementIds(); Document document = uiDocument.Document; // First find the selected equipment and get the correct connector foreach (ElementId id in selectedIds) { Element e = document.GetElement(id); if (e is FamilyInstance) { FamilyInstance fi = e as FamilyInstance; Family family = fi.Symbol.Family; if (family.FamilyCategory.Name == "Mechanical Equipment") { csi = fi.MEPModel.ConnectorManager.Connectors.ForwardIterator(); while (csi.MoveNext()) { Connector conn = csi.Current as Connector; if (conn.Direction == FlowDirectionType.Out && conn.DuctSystemType == DuctSystemType.SupplyAir) { connector1 = conn; break; } } } } } // next find the second selected item to connect to foreach (ElementId id in selectedIds) { Element e = document.GetElement(id); if (e is FamilyInstance) { FamilyInstance fi = e as FamilyInstance; Family family = fi.Symbol.Family; if (family.FamilyCategory.Name != "Mechanical Equipment") { csi = fi.MEPModel.ConnectorManager.Connectors.ForwardIterator(); while (csi.MoveNext()) { if (null == connector2) { Connector conn = csi.Current as Connector; // make sure to choose the connector in line with the first connector if (Math.Abs(conn.Origin.Y - connector1.Origin.Y) < 0.001) { connector2 = conn; break; } } } } } } Duct duct = null; if (null != connector1 && null != connector2) { // find a duct type FilteredElementCollector collector = new FilteredElementCollector(uiDocument.Document); collector.OfClass(typeof(DuctType)); // Use Linq query to make sure it is one of the rectangular duct types var query = from element in collector where element.Name.Contains("Mitered Elbows") == true select element; // use extension methods to get first duct type DuctType ductType = collector.Cast<DuctType>().First<DuctType>(); if (null != ductType) { duct = uiDocument.Document.Create.NewDuct(connector1, connector2, ductType); } } return duct; } |
配管とダクト断熱材とライニングを、ダクトと配管に関連付けられた個別のオブジェクトとして追加できます。ダクトまたは配管に関連付けられている断熱材要素の ID は、静的メソッド InsulationLiningBase.GetInsulationIds()を使用して取得し、ライニング要素の ID は、静的メソッド InsulationLiningBase.GetLiningIds()を使用して取得できます。
特定のダクト、配管、継手、付属品、コンテンツに関連付けられた新しい断熱材を作成するには、対応する静的メソッドダクト DuctInsulation.Create()または PipeInsulation.Create()を使用します。DuctLining.Create()を使用すると、任意のダクト、継手、付属品の内側に適用されたライニングの新しいインスタンスを作成できます。