Hello
My addin is attempting to create a Pipe. I have run into a problem if the user's Revit Project type is Architectural, Construction or Structural.
If I run my Addin when the user has these kinds of projects open, then I cannot create a Pipe because there are no PipeTypes loaded into the project. See my code below that you can run in a Non-MEP Project and it will show no PipeTypes are loaded.
Is this normal? Do you know how I can create a Pipe when the user is in a Non-MEP Project?
Some relevant information:
Run this code in your own version of Revit to replicate the error (No PipeTypes loaded in Non-MEP Projects):
[TransactionAttribute(TransactionMode.Manual)] [RegenerationAttribute(RegenerationOption.Manual)] public class Lab1PlaceGroup : IExternalCommand { public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiApp = commandData.Application; Document doc = uiApp.ActiveUIDocument.Document; Transaction trans = new Transaction(doc); trans.Start("Test"); #region Determine Pipe Types available in this project /* * Knowtice that in a MEP Project we can find the Pipe Types: "Standard" & "Plastic" * But in any other project (Architectural, Construction, Structural) there are no Pipe Types found * * Note: In Revit 2014 we can find the pipe type "Default" */ PipeType pipeType = null; FilteredElementCollector collector = new FilteredElementCollector(doc); collector.OfCategory(BuiltInCategory.OST_PipeCurves); collector.OfClass(typeof(ElementType)); foreach (Element ptype in collector) { TaskDialog.Show("Name: " + ptype.Name, "Notification"); if (string.Compare(ptype.Name, "standard", true) == 0) { pipeType = ptype as PipeType; break; } } #endregion Pipe pipe = doc.Create.NewPipe(new XYZ(1, 1, 1), new XYZ(5, 5, 5), pipeType); //PipeSystemType.DomesticColdWater); trans.Commit(); return Result.Succeeded; } }
Dear Sam,
You need atleast one pipe type before creating new ones.
If you dont have any pipe type in template then i suggest change the template, because if you are creating pipe types it is very strenge that template does not have any !!!...
Regards,
Nitin.
Dear Sam,
You may be able to use the copy and paste API to copy a pipe type from some existing MEP project into a non-MEP one:
Unfortunately, this is not available in Revit 2013, only from 2014 onwards.
Best regards,
Jeremy