M

Pipe.Create

Description:
Creates a new pipe from two points.
Overloads (3):
Create(Document,ElementId,ElementId,ElementId,XYZ,XYZ)
public static Pipe Create(
	Document document,
	ElementId systemTypeId,
	ElementId pipeTypeId,
	ElementId levelId,
	XYZ startPoint,
	XYZ endPoint
)
  • document
    The document.
  • systemTypeId
    The ElementId of the piping system type.
  • pipeTypeId
    The ElementId of the pipe type.
  • levelId
    The level ElementId for the pipe.
  • startPoint
    The start point of the pipe.
  • endPoint
    The end point of the pipe.
Return Value Pipe The pipe.
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;
}
  • 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 too close: for MEPCurve, the minimum length is 1/10 inch.
  • A non-optional argument was null