NewPipe Method (XYZ, XYZ, PipeType)


Adds a new pipe into the document, using two points and pipe type.

Namespace: Autodesk.Revit.Creation
Assembly: RevitAPI (in RevitAPI.dll) Version: 2015.0.0.0 (2015.0.0.0)

Syntax

C#
[ObsoleteAttribute("This method is obsolete in Revit 2015. Please use Pipe.Create() instead.")]
public Pipe NewPipe(
	XYZ point1,
	XYZ point2,
	PipeType pipeType
)
Visual Basic
<ObsoleteAttribute("This method is obsolete in Revit 2015. Please use Pipe.Create() instead.")> _
Public Function NewPipe ( _
	point1 As XYZ, _
	point2 As XYZ, _
	pipeType As PipeType _
) As Pipe
Visual C++
[ObsoleteAttribute(L"This method is obsolete in Revit 2015. Please use Pipe.Create() instead.")]
public:
Pipe^ NewPipe(
	XYZ^ point1, 
	XYZ^ point2, 
	PipeType^ pipeType
)

Parameters

point1
Type: Autodesk.Revit.DB XYZ
The first point of the pipe.
point2
Type: Autodesk.Revit.DB XYZ
The second point of the pipe.
pipeType
Type: Autodesk.Revit.DB.Plumbing PipeType
The type of the pipe.

Return Value

If creation was successful then a new pipe is returned, otherwise an exception with failure information will be thrown.

Examples

Copy C#
public Pipe CreateNewPipe(Document document, ElementId systemTypeId, ElementId levelId)
{
    // 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 = Pipe.Create(document, systemTypeId, pipeType.Id, levelId, p1, p2);
    }

    return pipe;
}
Copy C#
public Pipe CreateNewPipe(Document document, ElementId systemTypeId, ElementId levelId)
{
    // 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 = Pipe.Create(document, systemTypeId, pipeType.Id, levelId, p1, p2);
    }

    return pipe;
}
Copy C#
public Pipe CreateNewPipe(Document document, ElementId systemTypeId, ElementId levelId)
{
    // 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 = Pipe.Create(document, systemTypeId, pipeType.Id, levelId, p1, p2);
    }

    return pipe;
}
Copy C#
public Pipe CreateNewPipe(Document document, ElementId systemTypeId, ElementId levelId)
{
    // 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 = Pipe.Create(document, systemTypeId, pipeType.Id, levelId, p1, p2);
    }

    return pipe;
}
Copy VB.NET
Public Function CreateNewPipe(document As Document, systemTypeId As ElementId, levelId As ElementId) As Pipe
    ' find a pipe type


    Dim collector As New FilteredElementCollector(document)
    collector.OfClass(GetType(PipeType))
    Dim pipeType As PipeType = TryCast(collector.FirstElement(), PipeType)

    Dim pipe__1 As Pipe = Nothing
    If pipeType IsNot Nothing Then
        ' create pipe between 2 points
        Dim p1 As New XYZ(0, 0, 0)
        Dim p2 As New XYZ(10, 0, 0)

        pipe__1 = Pipe.Create(document, systemTypeId, pipeType.Id, levelId, p1, p2)
    End If

    Return pipe__1
End Function

Exceptions

Exception Condition
Autodesk.Revit.Exceptions ArgumentNullException Thrown when the input argument point1 or point2 is a null reference ( Nothing in Visual Basic) .
Autodesk.Revit.Exceptions InvalidOperationException Thrown when the pipe cannot be created or regenerate fails.

See Also

ArchiLabs

Stop fighting Revit automation.

Build repeatable BIM design and documentation workflows with scripts, data, and AI in one place, without wrestling brittle one-off automations.

Try ArchiLabs →