Dear All,
I am really stuck that, i am not able to create Pipe or Duct-Accesories Like Normal,End Cap, Valves using Code. Using Method Like
Doc.Create.NewUnionFitting(Connector1, Connector 2)
Doc.Create.NewElbowFitting(Connector1, Connector 2)
etc. I do not want ot use NewFamilyInstance() Method because this give rotation issue in offset drawing.
Please help me, if any one know how to resolve this.
Creating pipes was extremely difficult for myself also. But I figured out how to do it. But there are some caveats depending on what version of Revit you are using and what type of project you have open.
For Revit 2014:
- If you are not in a MEP project: you can only create standard pipes AFAIK. AFAIK it has to do with the fact that the System Families (for pipes) are not loaded in non-MEP projects
For Revit 2013:
- You can only create a pipe inside a MEP project
Heres my code I use:
public void createPipe(Document doc, XYZ strt, XYZ end) { #region Get Standard Pit Type PipeType pipeType = null; FilteredElementCollector collector = new FilteredElementCollector(doc); collector.OfCategory(BuiltInCategory.OST_PipeCurves); collector.OfClass(typeof(ElementType)); foreach (Element ptype in collector) { // DEBUG // Just use first type found //pipeType = ptype as PipeType; EXDSMessage("Type: " + ptype.Name); // END DEBUG System.Windows.MessageBox.Show("Name: " + ptype.Name); if (string.Compare(ptype.Name, "standard", true) == 0) { System.Windows.MessageBox.Show("Name: " + ptype.Name); pipeType = ptype as PipeType; break; } } #endregion //Pipe pipe = Pipe.Create(doc, pipeType.Id, pipeType.Id, levelType.Id, strt, end); Pipe pipe = doc.Create.NewPipe(strt, end, pipeType); }