Align Pipes at bottom

This is an old Revit macro I’ve created to align pipes to the bottom (BOP or BOI). It asks for a pipe to be used as reference and the pipes to be aligned. You need to create a new macro and paste the code below replacing all the content of the file. After this you will se a module named Align_Pipe

The module should look like this

 * Created by SharpDevelop.
 * User: pderendinger
 * Date: 10/5/2015
 * Time: 5:40 PM
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
using System;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI.Selection;
using System.Collections.Generic;
using System.Linq;

namespace Align
 public partial class ThisApplication
  private void Module_Startup(object sender, EventArgs e)


  private void Module_Shutdown(object sender, EventArgs e)


  #region Revit Macros generated code
  public void Align_Pipe()

   UIDocument uidoc = this.ActiveUIDocument;
   Document doc = uidoc.Document;
   TaskDialog.Show("Select Reference","Select Pipe as Reference");
   Reference pr = uidoc.Selection.PickObject(ObjectType.Element);
   Element element = doc.GetElement(pr);
  double prodia= 0; 
  double proff= 0;
   if (element.Category.Name == "Pipes")
   prodia= element.LookupParameter("Outside Diameter").AsDouble();
   proff= element.LookupParameter("Offset").AsDouble();
    TaskDialog.Show("Error","Select a Pipes to align");
   double h = proff - (prodia/2);
   TaskDialog.Show("Select Elements","Select Pipes to align");
   // ask user 
   IList <Element> ps = uidoc.Selection.PickElementsByRectangle();
   Transaction t = new Transaction(doc,"Set offset");
   foreach (Element e in ps) 
    if (e.Category.Name == "Pipes")
             double psodia = e.LookupParameter("Outside Diameter").AsDouble();
             double hi =(h + (psodia/2));
  private void InternalStartup()
   this.Startup += new System.EventHandler(Module_Startup);
   this.Shutdown += new System.EventHandler(Module_Shutdown);

Hope you find it useful, let me know your comments!


Leave a Reply

Your email address will not be published. Required fields are marked *