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).

1 comment:

Taylor Odell said...

Could this also work to link door schedules to door details that have been placed on sheets?

Adding a parameter to the door families that will allow a detail drawings to fill in a head, jamb, sill detail section of the door schedule with the drawings (detail) number and sheet when that detail view is placed on a sheet?