Please try the following code and tell me the results:
FilteredElementCollector collector = new FilteredElementCollector(doc); collector.OfCategory(BuiltInCategory.OST_PipingSystem).Where(ps => ps.Name == "Domestic Cold Water"); PipingSystem pipesystem = collector.Cast<PipingSystem>().FirstOrDefault(); Autodesk.Revit.DB.Plumbing.Pipe.Create(doc, pipetype1.Id, pipesystem.Id, level1.Id, new XYZ(0, 0, 0), new XYZ(1250, 1010, 0));
If it satisfies your need please mark this reply as an answer.