Create Method (Document, ElementId, ElementId, ElementId, XYZ, XYZ)


Creates a new pipe from two points.

Namespace: Autodesk.Revit.DB.Plumbing
Assembly: RevitAPI (in RevitAPI.dll) Version: 19.0.0.0 (19.0.0.405)
Since: 2014

Syntax

C#
public static Pipe Create(
	Document document,
	ElementId systemTypeId,
	ElementId pipeTypeId,
	ElementId levelId,
	XYZ startPoint,
	XYZ endPoint
)
Visual Basic
Public Shared Function Create ( _
	document As Document, _
	systemTypeId As ElementId, _
	pipeTypeId As ElementId, _
	levelId As ElementId, _
	startPoint As XYZ, _
	endPoint As XYZ _
) As Pipe
Visual C++
public:
static Pipe^ Create(
	Document^ document, 
	ElementId^ systemTypeId, 
	ElementId^ pipeTypeId, 
	ElementId^ levelId, 
	XYZ^ startPoint, 
	XYZ^ endPoint
)

Parameters

document
Type: Autodesk.Revit.DB Document
The document.
systemTypeId
Type: Autodesk.Revit.DB ElementId
The ElementId of the piping system type.
pipeTypeId
Type: Autodesk.Revit.DB ElementId
The ElementId of the pipe type.
levelId
Type: Autodesk.Revit.DB ElementId
The level ElementId for the pipe.
startPoint
Type: Autodesk.Revit.DB XYZ
The start point of the pipe.
endPoint
Type: Autodesk.Revit.DB XYZ
The end point of the pipe.

Return Value

The pipe.

Examples

Copy C#
public static 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 Shared 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 ArgumentException The systemTypeId is not valid piping system type. -or- The pipe type pipeTypeId is not valid pipe type. -or- The ElementId levelId is not a Level. -or- The points of startPoint and endPoint are equal.
Autodesk.Revit.Exceptions ArgumentNullException A non-optional argument was NULL
Autodesk.Revit.Exceptions DisabledDisciplineException None of the following disciplines is enabled: Mechanical Electrical Piping.

See Also

ArchiLabs Desktop

Put AI to work inside Revit.

Give Desktop your instructions and project files to build Revit families, update model elements, and create views and schedules. Works directly in Revit and AutoCAD.

Explore Desktop →