Tuesday, June 24, 2014

Revit Lookup 2015 Addin

During my class (BIM Managers Guide to Automating Revit Using Macros) at RTC in Schaumburg (Chicago) last week, I mentioned the Revit Lookup addin. Afterwards several people asked where they could download a compiled version. I compiled the most recent source from https://github.com/jeremytammik/RevitLookup/ and uploaded it to my blog so you can download it (below).

Download
Revit Lookup 2015

Install Instructions
Extract the 2 files to C:\ProgramData\Autodesk\Revit\Addins\2015\


If you are interested in 2013 and 2014 versions you can find them in a blog post from last year: http://revitcoaster.blogspot.com/2013/09/creating-macros-larug-sept-2013.html 

Thursday, June 05, 2014

View Schedule with Detail Numbers Macro for Revit

A question was posted on http://revitforum.org about showing a view's detail number in a view list schedule. Revit has a parameter for the Detail Number (see first image) but it isn't accessible to add in a view list schedule.

Original post: http://www.revitforum.org/architecture-general-revit-questions/20119-detail-number-view-list-schedule.html




















Solution

Step 1
Create a View List schedule (or edit an existing one) and add a new text Parameter named "Detail_Number" (notice the _ in the name)






















Step 2
Create a new macro with the following routine and run it

public void DetailNumber()
{
    UIDocument uidoc = this.ActiveUIDocument;
    Document doc = uidoc.Document;
  
    string strDetailNumber = "Detail_Number";         
  
    FilteredElementCollector collector = new FilteredElementCollector(doc);
    ICollection<Element> collection = collector.OfClass(typeof(View)).ToElements();
  
    using (Transaction t = new Transaction(doc, "Detail Number"))
    {
        t.Start();
      
        foreach(Element e in collection)
        {
            View v = e as View;
          
            try
            {
                Parameter bpDetailNumber = v.get_Parameter(BuiltInParameter.VIEWPORT_DETAIL_NUMBER);
                v.get_Parameter(strDetailNumber).Set(bpDetailNumber.AsString());
            }
            catch
            {
              
            }
          
        }
      
        t.Commit();
    }
}


Results
All the views that are on sheets now have the Detail Number copied into the Detail_Number parameter.



















Run the macro whenever you want to update the values in the new parameter to reflect the current state of the project (aka is doesn't auto update and needs to be run manually).